Leadtools.Codecs Namespace > RasterCodecs Class > StartFeedLoad Method : StartFeedLoad(Int32,CodecsLoadByteOrder) Method |
Resulting image pixel depth. Valid values are:
Value | Meaning |
---|---|
0 | Keep the original file's pixel depth (Do not convert). |
1 to 8 | The specified bits per pixel in the resulting image. |
12 | 12 bits per pixel in the resulting image. |
16 | 16 bits per pixel in the resulting image. |
24 | 24 bits per pixel in the resulting image. |
32 | 32 bits per pixel in the resulting image. |
48 | 48 bits per pixel in the resulting image. |
64 | 64 bits per pixel in the resulting image. |
The desired color order. Possible values are:
Value | Meaning |
---|---|
CodecsLoadByteOrder.Rgb | Red, green, and blue color order in memory |
CodecsLoadByteOrder.Bgr | Blue, green, and red color order in memory |
CodecsLoadByteOrder.Gray | 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are only supported in the Document/Medical Imaging editions. |
CodecsLoadByteOrder.RgbOrGray | Load the image as red, green, blue OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical Imaging editions |
CodecsLoadByteOrder.BgrOrGray | Load the image as blue, green, red OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical Imaging editions |
CodecsLoadByteOrder.Romm | ROMM order. ROMM only supports 24 and 48-bit images |
CodecsLoadByteOrder.BgrOrGrayOrRomm | Load the image as red, green, blue OR as a 12 or 16-bit grayscale image OR as ROMM. 12 and 16-bit grayscale images are supported in the Document/Medical Imaging editions only. ROMM only supports 24 and 48-bit color images. |
public void StartFeedLoad( int bitsPerPixel, CodecsLoadByteOrder order )
'Declaration Public Overloads Sub StartFeedLoad( _ ByVal bitsPerPixel As Integer, _ ByVal order As CodecsLoadByteOrder _ )
'Usage Dim instance As RasterCodecs Dim bitsPerPixel As Integer Dim order As CodecsLoadByteOrder instance.StartFeedLoad(bitsPerPixel, order)
public void StartFeedLoad( int bitsPerPixel, CodecsLoadByteOrder order )
-(BOOL)startFeedLoad:(unsigned int)bitsPerPixel order:(LTCodecsLoadByteOrder)order error:(NSError**)outError;
public FeedCallbackThunk startFeedLoad(int bitsPerPixel, CodecsLoadByteOrder order)
function Leadtools.Codecs.RasterCodecs.StartFeedLoad(Int32,CodecsLoadByteOrder)( bitsPerPixel , order )
public: void StartFeedLoad( int bitsPerPixel, CodecsLoadByteOrder order )
Resulting image pixel depth. Valid values are:
Value | Meaning |
---|---|
0 | Keep the original file's pixel depth (Do not convert). |
1 to 8 | The specified bits per pixel in the resulting image. |
12 | 12 bits per pixel in the resulting image. |
16 | 16 bits per pixel in the resulting image. |
24 | 24 bits per pixel in the resulting image. |
32 | 32 bits per pixel in the resulting image. |
48 | 48 bits per pixel in the resulting image. |
64 | 64 bits per pixel in the resulting image. |
The desired color order. Possible values are:
Value | Meaning |
---|---|
CodecsLoadByteOrder.Rgb | Red, green, and blue color order in memory |
CodecsLoadByteOrder.Bgr | Blue, green, and red color order in memory |
CodecsLoadByteOrder.Gray | 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are only supported in the Document/Medical Imaging editions. |
CodecsLoadByteOrder.RgbOrGray | Load the image as red, green, blue OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical Imaging editions |
CodecsLoadByteOrder.BgrOrGray | Load the image as blue, green, red OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical Imaging editions |
CodecsLoadByteOrder.Romm | ROMM order. ROMM only supports 24 and 48-bit images |
CodecsLoadByteOrder.BgrOrGrayOrRomm | Load the image as red, green, blue OR as a 12 or 16-bit grayscale image OR as ROMM. 12 and 16-bit grayscale images are supported in the Document/Medical Imaging editions only. ROMM only supports 24 and 48-bit color images. |
You must call the FeedLoad(Byte[],Int32,Int32) method to supply buffered data, and you must call StopFeedLoad when the loading is complete.
This file-load process is useful when receiving transmitted images, such as those on the Internet. It works the same way as the Load(String) or LoadAsync(String,LeadRect,Int32,CodecsLoadByteOrder,Int32,Int32,Object) methods, except that your code supplies the image data. The file-load process works as follows:
Whenever it has enough data to do so, the file-load process behaves the same as in the Load(String) or LoadAsync(String,LeadRect,Int32,CodecsLoadByteOrder,Int32,Int32,Object) methods. It allocates and begins loading the image. It calls your LoadImage event handler, if one is specified, whenever it has enough data in its input buffer.
The file-load process updates information in the Leadtools.RasterImage when it has received enough information to do so. The file-load process will make the first call to your event handler whenever this information is available.
CodecsLoadByteOrder.Gray is only valid for 12 and 16-bit grayscale images. Support for 12 and 16-bit grayscale images is only available in the Document/Medical Imaging editions.
This method cannot be used in combination with StartRedirecting.
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.
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ImageProcessing Imports Leadtools.ImageProcessing.Color Imports Leadtools.Drawing Public Sub FeedLoadExample() Dim codecs As RasterCodecs = New RasterCodecs() Dim url As String = "http://www.leadtools.com/images/web-header.jpg" Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "FeedLoad.bmp") ' Create a WebRequest for the URL Dim request As WebRequest = WebRequest.Create(url) request.Proxy.Credentials = CredentialCache.DefaultCredentials ' reduce the timeout to 20sec request.Timeout = 20000 Dim response As WebResponse = request.GetResponse() Try Dim strm As Stream = response.GetResponseStream() ' Read chunks from the stream and feed load to the image codecs.StartFeedLoad(0, CodecsLoadByteOrder.BgrOrGray) Const bufferSize As Integer = 1024 Dim buffer(bufferSize - 1) As Byte Dim read As Integer Do System.Windows.Forms.Application.DoEvents() read = strm.Read(buffer, 0, bufferSize) Console.WriteLine("Downloading {0} bytes", read) If read > 0 Then codecs.FeedLoad(buffer, 0, read) End If Loop While read > 0 Finally response.Close() End Try Dim image As RasterImage = codecs.StopFeedLoad() ' Save the image to disk codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24) image.Dispose() ' Clean up codecs.Dispose() End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Color; public void FeedLoadExample() { RasterCodecs codecs = new RasterCodecs(); string url = @"http://www.leadtools.com/images/page_graphics/leadlogo.png"; string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "FeedLoad.bmp"); // Create a WebRequest for the URL WebRequest request = WebRequest.Create(url); request.Proxy.Credentials = CredentialCache.DefaultCredentials; // reduce the timeout to 20sec request.Timeout = 20000; WebResponse response = request.GetResponse(); try { Stream strm = response.GetResponseStream(); // Read chunks from the stream and feed load to the image codecs.StartFeedLoad(0, CodecsLoadByteOrder.BgrOrGray); const int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; int read; do { System.Windows.Forms.Application.DoEvents(); read = strm.Read(buffer, 0, bufferSize); Console.WriteLine("Downloading {0} bytes", read); if (read > 0) codecs.FeedLoad(buffer, 0, read); } while (read > 0); } finally { response.Close(); } RasterImage image = codecs.StopFeedLoad(); // Save the image to disk codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24); image.Dispose(); // Clean up codecs.Dispose(); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
//RasterCodecsExamples.prototype.FeedLoadExample = function ( ) //{ // Tools.SetLicense ( ) ; // with ( Leadtools ) { with ( Leadtools.Codecs ) { // var codecs = new RasterCodecs(); // var url = "http://www.leadtools.com/images/page_graphics/leadlogo.png"; // var destFileName = "FeedLoad.bmp"; // // Create a WebRequest for the URL // WebRequest request = WebRequest.Create(url); // request.Proxy.Credentials = CredentialCache.DefaultCredentials; // WebResponse response = await request.GetResponseAsync(); // try // { // Stream strm = response.GetResponseStream(); // // Read chunks from the stream and feed load to the image // codecs.StartFeedLoad(0, CodecsLoadByteOrder.BgrOrGray); // const int bufferSize = 1024; // byte[] buffer = new byte[bufferSize]; // int read; // do // { // read = strm.Read(buffer, 0, bufferSize); // console.info("Downloading {0} bytes", read); // if (read > 0) // codecs.FeedLoad(buffer, 0, read); // } // while (read > 0); // } // finally // { // response.Dispose(); // } // RasterImage image = codecs.StopFeedLoad(); // // Save the image 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(); //} //
using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Color; public async Task FeedLoadExample() { RasterCodecs codecs = new RasterCodecs(); string url = @"http://www.leadtools.com/images/page_graphics/leadlogo.png"; string destFileName = @"FeedLoad.bmp"; // Create a WebRequest for the URL WebRequest request = WebRequest.Create(url); request.Proxy.Credentials = CredentialCache.DefaultCredentials; WebResponse response = await request.GetResponseAsync(); try { Stream strm = response.GetResponseStream(); // Read chunks from the stream and feed load to the image codecs.StartFeedLoad(0, CodecsLoadByteOrder.BgrOrGray); const int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; int read; do { read = strm.Read(buffer, 0, bufferSize); Debug.WriteLine("Downloading {0} bytes", read); if (read > 0) codecs.FeedLoad(buffer, 0, read); } while (read > 0); } finally { response.Dispose(); } RasterImage image = codecs.StopFeedLoad(); // Save the image 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(); }