Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.17
StartFeedLoad(Int32,CodecsLoadByteOrder) Method
See Also  Example
Leadtools.Codecs Namespace > RasterCodecs Class > StartFeedLoad Method : StartFeedLoad(Int32,CodecsLoadByteOrder) Method




bitsPerPixel

Resulting image pixel depth. Valid values are:

ValueMeaning
0Keep the original file's pixel depth (Do not convert).
1 to 8The specified bits per pixel in the resulting image.
1212 bits per pixel in the resulting image.
1616 bits per pixel in the resulting image.
2424 bits per pixel in the resulting image.
3232 bits per pixel in the resulting image.
4848 bits per pixel in the resulting image.
6464 bits per pixel in the resulting image.

order

The desired color order. Possible values are:

ValueMeaning
CodecsLoadByteOrder.RgbRed, green, and blue color order in memory
CodecsLoadByteOrder.BgrBlue, green, and red color order in memory
CodecsLoadByteOrder.Gray12 or 16-bit grayscale image. 12 and 16-bit grayscale images are only supported in the Document/Medical Imaging editions.
CodecsLoadByteOrder.RgbOrGrayLoad 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.BgrOrGrayLoad 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.RommROMM order. ROMM only supports 24 and 48-bit images
CodecsLoadByteOrder.BgrOrGrayOrRommLoad 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.

Initializes a file-load process in which you control the input stream.

Syntax

Visual Basic (Declaration) 
Overloads Public Sub StartFeedLoad( _
   ByVal bitsPerPixel As Integer, _
   ByVal order As CodecsLoadByteOrder _
) 
Visual Basic (Usage)Copy Code
Dim instance As RasterCodecs
Dim bitsPerPixel As Integer
Dim order As CodecsLoadByteOrder
 
instance.StartFeedLoad(bitsPerPixel, order)
C# 
public void StartFeedLoad( 
   int bitsPerPixel,
   CodecsLoadByteOrder order
)
Managed Extensions for C++ 
public: void StartFeedLoad( 
   int bitsPerPixel,
   CodecsLoadByteOrder order
) 
C++/CLI 
public:
void StartFeedLoad( 
   int bitsPerPixel,
   CodecsLoadByteOrder order
) 

Parameters

bitsPerPixel

Resulting image pixel depth. Valid values are:

ValueMeaning
0Keep the original file's pixel depth (Do not convert).
1 to 8The specified bits per pixel in the resulting image.
1212 bits per pixel in the resulting image.
1616 bits per pixel in the resulting image.
2424 bits per pixel in the resulting image.
3232 bits per pixel in the resulting image.
4848 bits per pixel in the resulting image.
6464 bits per pixel in the resulting image.

order

The desired color order. Possible values are:

ValueMeaning
CodecsLoadByteOrder.RgbRed, green, and blue color order in memory
CodecsLoadByteOrder.BgrBlue, green, and red color order in memory
CodecsLoadByteOrder.Gray12 or 16-bit grayscale image. 12 and 16-bit grayscale images are only supported in the Document/Medical Imaging editions.
CodecsLoadByteOrder.RgbOrGrayLoad 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.BgrOrGrayLoad 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.RommROMM order. ROMM only supports 24 and 48-bit images
CodecsLoadByteOrder.BgrOrGrayOrRommLoad 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.

Example

Visual BasicCopy Code
RasterCodecs.FeedLoad
      Public Sub FeedLoadExample()
         RasterCodecs.Startup()
         Dim codecs As RasterCodecs = New RasterCodecs()

         Dim url As String = "http://www.leadtools.com/images/web-header.jpg"
         Dim destFileName As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\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
               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()
         RasterCodecs.Shutdown()
      End Sub
C#Copy Code
RasterCodecs.FeedLoad 
      public void FeedLoadExample() 
      { 
         RasterCodecs.Startup(); 
         RasterCodecs codecs = new RasterCodecs(); 
 
         string url = @"http://www.leadtools.com/images/web-header.jpg"; 
         string destFileName = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\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 
            { 
               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(); 
         RasterCodecs.Shutdown(); 
      }

Remarks

You must call the FeedLoad 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 method, except that your code supplies the image data. The file-load process works as follows:

  1. You call the StartFeedLoad method to initialize the file-load process.
  2. You create a buffer, and each time you fill it with information, you call the FeedLoad method, which sends the data to the file-load process just as if the data were being read from a file on disk.
  3. Whenever it has enough data to do so, the file-load process behaves the same as in the Load method. 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 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.

  4. At any time after calling StartFeedLoad, you can call CancelFeedLoad to gracefully abort the feed load operation. This allows you to end the feed load process without throwing an exception.
  5. To end the file-load process, you call the StopFeedLoad method, which cleans up the process, and returns the loaded RasterImage, if successful. If you call this method before supplying the complete file, it will successfully clean up the process, but will throw an exception. You should catch the exception if the load is canceled purposely.

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.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also