Asynchronously loads the specified page from an image stream using default options.
[AsyncStateMachineAttribute(this System.Type)]
public static Task<RasterImage> LoadAsync(
this RasterCodecs rasterCodecs,
ILeadStream stream,
int pageNumber
)
rasterCodecs
RasterCodecs object to perform the operation.
stream
A Stream containing the image data to load.
pageNumber
The 1-based page number.
A Task
that represents the asynchronous operation. TResult
: The RasterImage object that this method loads. See remarks for the usage of this object.
This topic is part of RasterCodecs
support for .NET async/await
support. Refer to RasterCodecs Async Operations for more information.
The stream can point to any supported image file format and bits per pixel, whether compressed or uncompressed.
This method will load a single page from a multipage file. The resulting image will have the same bits/pixel and color order value of the image as it was stored in the stream.
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 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.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Svg;
using LeadtoolsExamples.Common;
public async void LoadAsync2Example()
{
// For .NET Framework: Add a reference to Leadtools.Async to get the async support as extension methods
// For .NET Standard: async support is included.
// Load the specified page number from the PDF image in a remote URL
string address = @"https://demo.leadtools.com/images/pdf/leadtools.pdf";
int pageNumber = 2;
Uri uri = new Uri(address);
using (RasterCodecs codecs = new RasterCodecs())
{
// Create an ILeadStream object to the URI
using (ILeadStream leadStream = await LeadStream.Factory.FromUri(uri))
{
using (RasterImage image = await codecs.LoadAsync(leadStream, pageNumber))
{
Console.WriteLine("Image loaded from : {0}", uri);
Console.WriteLine("Width: {0}", image.ImageWidth);
Console.WriteLine("Height: {0}", image.ImageHeight);
Console.WriteLine("BitsPerPixel: {0}", image.BitsPerPixel);
Console.WriteLine("BytesPerLine: {0}", image.BytesPerLine);
}
}
}
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Drawing
Imports Leadtools.Svg
Public Async Sub LoadAsync2Example()
' For .NET Framework: Add a reference To Leadtools.Async To Get the async support As extension methods
' For .NET Standard Async support Is included.
' Load the specified page number from the PDF image in a remote URL
Dim address As String = "https://demo.leadtools.com/images/pdf/leadtools.pdf"
Dim pageNumber As Integer = 2
Dim uri As New Uri(address)
Using codecs As New RasterCodecs()
' Create an ILeadStream object to the URI
Using stream As ILeadStream = Await LeadStream.Factory.FromUri(uri)
Using image As RasterImage = Await codecs.LoadAsync(stream, pageNumber)
Console.WriteLine("Image loaded from : {0}", uri)
Console.WriteLine("Width: {0}", image.ImageWidth)
Console.WriteLine("Height: {0}", image.ImageHeight)
Console.WriteLine("BitsPerPixel: {0}", image.BitsPerPixel)
Console.WriteLine("BytesPerLine: {0}", image.BytesPerLine)
End Using
End Using
End Using
End Sub
For .NET Framework: A reference to the Leadtools.Async.dll assembly is required to use this functionality.
For .NET Standard: This functionality is included in the Leadtools.Codecs.dll assembly.
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document