LEADTOOLS Image File Support (Leadtools.Codecs assembly)

LoadAsync(ILeadStream,LeadRect) Method

Show in webframe
Example 







An Leadtools.ILeadStream containing the image data to load.
A Leadtools.LeadRect describing the tile/area of the image to load.
Loads the specified rectangle from the specified image stream using the specified options asynchronously.
Syntax
public IAsyncOperation<RasterImage> LoadAsync( 
   ILeadStream stream,
   LeadRect tile
)
'Declaration
 
Public Overloads Function LoadAsync( _
   ByVal stream As ILeadStream, _
   ByVal tile As LeadRect _
) As IAsyncOperation(Of RasterImage)
'Usage
 
Dim instance As RasterCodecs
Dim stream As ILeadStream
Dim tile As LeadRect
Dim value As IAsyncOperation(Of RasterImage)
 
value = instance.LoadAsync(stream, tile)
public IAsyncOperation<RasterImage> LoadAsync( 
   ILeadStream stream,
   LeadRect tile
)

            

            
 function Leadtools.Codecs.RasterCodecs.LoadAsync(ILeadStream,LeadRect)( 
   stream ,
   tile 
)
public:
IAsyncOperation<RasterImage^>^ LoadAsync( 
   ILeadStream^ stream,
   LeadRect tile
) 

Parameters

stream
An Leadtools.ILeadStream containing the image data to load.
tile
A Leadtools.LeadRect describing the tile/area of the image to load.

Return Value

When this method completes, it returns the image as a Leadtools.RasterImage.
Remarks

This method loads a section of an image file (any format). The section begins is defined by tile rectangle.

LEADTOOLS will attempt to load corrupted files so you can see at least a portion of the image. For these images, the load methods succeed, but LoadStatus will return an error code.

Use the CodecsLoadOptions class to set up other load option parameters before calling this method.

Support for 12 and 16-bit grayscale images is only available in the Document/Medical Imaging editions.

For supported formats, refer to Summary of All Supported Image File Formats.

LEADTOOLS loads all PDF files as Raster PDF uncompressed RasterImageFormat.RasPdf, regardless of the compression and color space used when saving the file.

The RasterCodecs class supports loading image files asynchronously using the LoadAsync methods. When calling any of these methods, the caller thread will not be blocked and the method will return instantly with an instance of Leadtools.RasterImage that is in a loading status (RasterImage.IsLoading set to true). You should not use the other properties of this object while the object is in loading status.

When the RasterCodecs object finishes loading the image, the various properties of the Leadtools.RasterImage will be populated with the image information and data and the RasterImage.IsLoading property will be set to false.

Do not poll the RasterImage.IsLoading property to determine whether the image has finished loading. Instead, subscribe to the IAsyncOperation.Completed event to get notification when the LoadAsync(String,LeadRect,Int32,CodecsLoadByteOrder,Int32,Int32,Object) operation has completed and whether any errors occurred.

When this method completes, it returns the image as a Leadtools.RasterImage.

The CodecsLoadOptions.AllPages property controls whether RasterCodecs will try to load all pages or just the first page if the image data contains multiple pages.

Example
Copy Code  
RasterCodecsExamples.prototype.LoadTileFile1Example = function ( ) 
{
   Tools.SetLicense ( ) ;
   with (Leadtools) {
      with (Leadtools.Codecs) {
         var codecs = new RasterCodecs();
         var image;
         var loadFile;
         var info;
         var srcFileName = "Assets\\Image1.cmp";
         var destFileName = "Image1_LoadTileFile1.bmp";

         // Get the image dimension
         return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (ldFile) {
            loadFile = ldFile;
            return codecs.getInformationAsync(LeadStreamFactory.create(loadFile), false, 1)
         })
         .then(function (inf) {
            info = inf;

            // Load the lower right corner of the image
            var rc = LeadRectHelper.create(
               info.width / 2,
               info.height / 2,
               info.width / 2,
               info.height / 2);

            return codecs.loadAsync(LeadStreamFactory.create(loadFile), rc)
         })
         .then(function (img) {
            image = img;
            console.assert(image.width == (info.width / 2), "image.Width == (info.Width / 2)");
            console.assert(image.height == (info.height / 2), "image.Height == (info.Height / 2)");

            // Save this image back to disk
            return Tools.AppLocalFolder().createFileAsync(destFileName)
         })
         .then(function (saveFile) {
            return codecs.saveAsync(image, LeadStreamFactory.create(saveFile), RasterImageFormat.bmp, 24)
         })
         .then(function () {
            image.close();

            // Clean up
            codecs.close();
         });
      }
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;

      
public async Task LoadTileFile1Example()
{
   RasterCodecs codecs = new RasterCodecs();
   string srcFileName = @"Assets\Image1.cmp";
   string destFileName = @"Image1_LoadTileFile1.bmp";

   // Get the image dimension
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   CodecsImageInfo info = await codecs.GetInformationAsync(LeadStreamFactory.Create(loadFile), false, 1);

   // Load the lower right corner of the image
   LeadRect rc = LeadRectHelper.Create(
      info.Width / 2,
      info.Height / 2,
      info.Width / 2,
      info.Height / 2);

   RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile), rc);
   Assert.IsTrue(image.Width == (info.Width / 2));
   Assert.IsTrue(image.Height == (info.Height / 2));

   // Save this image back to disk
   StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName);
   await codecs.SaveAsync(image, LeadStreamFactory.Create(saveFile), RasterImageFormat.Bmp, 24);

   image.Dispose();

   // Clean up
   codecs.Dispose();
}
Requirements

Target Platforms

See Also

Reference

RasterCodecs Class
RasterCodecs Members
Overload List
Loading and Saving Images
Loading and Saving Large Tiff Files
Speeding Up 1-Bit Documents
Fast File Info

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.