Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.17
StartFeedGetInformation Method
See Also  Example
Leadtools.Codecs Namespace > RasterCodecs Class : StartFeedGetInformation Method




totalPages
true to query the file for total number of pages, false otherwise.
pageNumber
1-based index to the page number to query.
Initializes a file information process in which you control the input stream.

Syntax

Visual Basic (Declaration) 
Public Sub StartFeedGetInformation( _
   ByVal totalPages As Boolean, _
   ByVal pageNumber As Integer _
) 
Visual Basic (Usage)Copy Code
Dim instance As RasterCodecs
Dim totalPages As Boolean
Dim pageNumber As Integer
 
instance.StartFeedGetInformation(totalPages, pageNumber)
C# 
public void StartFeedGetInformation( 
   bool totalPages,
   int pageNumber
)
Managed Extensions for C++ 
public: void StartFeedGetInformation( 
   bool totalPages,
   int pageNumber
) 
C++/CLI 
public:
void StartFeedGetInformation( 
   bool totalPages,
   int pageNumber
) 

Parameters

totalPages
true to query the file for total number of pages, false otherwise.
pageNumber
1-based index to the page number to query.

Example

Visual BasicCopy Code
RasterCodecs.FeedGetInformation
      Public Sub FeedGetInformationExample()
         RasterCodecs.Startup()
         Dim codecs As New RasterCodecs()

         Dim url As String = "http://www.leadtools.com/images/web-header.jpg"

         ' Create a WebRequest for the URL
         Dim request As WebRequest = WebRequest.Create(url)
         request.Proxy.Credentials = CredentialCache.DefaultCredentials

         ' reduce the timeout to 20 sec
         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.StartFeedGetInformation(True, 1)

            Const bufferSize As Integer = 1024
            Dim buffer(bufferSize - 1) As Byte

            Dim more As Boolean

            Do
               Application.DoEvents()

               Dim read As Integer = strm.Read(buffer, 0, bufferSize)
               Console.WriteLine("Downloading {0} bytes", read)
               If (read > 0) Then
                  more = codecs.FeedGetInformation(buffer, 0, read)
               Else
                  ' no more image data in the stream
                  more = False
               End If
            Loop While more
         Finally
            response.Close()
         End Try

         Dim info As CodecsImageInfo = codecs.StopFeedGetInformation()

         ' Clean up
         codecs.Dispose()
         RasterCodecs.Shutdown()

         ' Show the information
         MessageBox.Show(info.ToString())
      End Sub
C#Copy Code
RasterCodecs.FeedGetInformation 
      public void FeedGetInformationExample() 
      { 
         RasterCodecs.Startup(); 
         RasterCodecs codecs = new RasterCodecs(); 
 
         string url = @"http://www.leadtools.com/images/web-header.jpg"; 
 
         // Create a WebRequest for the URL 
         WebRequest request = WebRequest.Create(url); 
         request.Proxy.Credentials = CredentialCache.DefaultCredentials; 
 
         // reduce the timeout to 20 sec 
         request.Timeout = 20000; 
 
         WebResponse response = request.GetResponse(); 
 
         try 
         { 
            Stream strm = response.GetResponseStream(); 
 
            // Read chunks from the stream and feed load to the image 
            codecs.StartFeedGetInformation(true, 1); 
 
            const int bufferSize = 1024; 
            byte[] buffer = new byte[bufferSize]; 
 
            bool more; 
 
            do 
            { 
               Application.DoEvents(); 
 
               int read = strm.Read(buffer, 0, bufferSize); 
               Console.WriteLine("Downloading {0} bytes", read); 
               if(read > 0) 
                  more = codecs.FeedGetInformation(buffer, 0, read); 
               else 
               { 
                  // no more image data in the stream 
                  more = false; 
               } 
            } 
            while(more); 
         } 
         finally 
         { 
            response.Close(); 
         } 
 
         CodecsImageInfo info = codecs.StopFeedGetInformation(); 
 
         // Clean up 
         codecs.Dispose(); 
         RasterCodecs.Shutdown(); 
 
         // Show the information 
         MessageBox.Show(info.ToString()); 
      }

Remarks

You must call the FeedGetInformation method to supply buffered data, and you must call StopFeedGetInformation when the process is complete.

This file information process is useful when receiving transmitted images, such as those on the Internet. It works the same way as the GetInformation method, except that your code supplies the image data. The file information process works as follows:

  1. You call the StartFeedGetInformation method to initialize the file information process.
  2. You create a buffer, and each time you fill it with information, you call the FeedGetInformation method, which sends the data to the file information process just as if the data were being read from a file on disk.

    If the FeedGetInformation returns true, this means the frameworks does not have enough data to get the information required; you must read more data and call the FeedGetInformation again. When FeedGetInformation returns false, the framework has gathered enough data and you can break out of the loop.

  3. At any time after calling StartFeedGetInformation, you can call CancelFeedGetInformation to gracefully abort the feed operation. This allows you to end the feed process without throwing an exception.
  4. To end the file information process, you call the StopFeedGetInformation method, which cleans up the process, and returns an instance of the CodecsImageInfo class if successful. If you call this method before enough image data is passed to gather the information, it will successfully clean up the process, but will throw an exception. You should catch the exception if the process is canceled purposely.

This method cannot be used in combination with StartRedirecting.

Specifying true for totalPages can cause the process to be slow for files with large number of pages.

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