Leadtools.Codecs Namespace > RasterCodecs Class : StartFeedGetInformation Method |
public void StartFeedGetInformation( bool totalPages, int pageNumber )
'Declaration Public Sub StartFeedGetInformation( _ ByVal totalPages As Boolean, _ ByVal pageNumber As Integer _ )
'Usage Dim instance As RasterCodecs Dim totalPages As Boolean Dim pageNumber As Integer instance.StartFeedGetInformation(totalPages, pageNumber)
public void StartFeedGetInformation( bool totalPages, int pageNumber )
-(BOOL)startFeedGetInformation:(BOOL)totalPages pageNumber:(int)pageNumber error:(NSError**)outError;
public FeedCallbackThunk startFeedGetInformation(boolean totalPages, int pageNumber)
function Leadtools.Codecs.RasterCodecs.StartFeedGetInformation( totalPages , pageNumber )
public: void StartFeedGetInformation( bool totalPages, int pageNumber )
You must call the FeedGetInformation(Byte[],Int32,Int32) 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(String,Boolean) method, except that your code supplies the image data. The file information process works as follows:
You create a buffer, and each time you fill it with information, you call the FeedGetInformation(Byte[],Int32,Int32) 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(Byte[],Int32,Int32) 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(Byte[],Int32,Int32) again. When FeedGetInformation(Byte[],Int32,Int32) returns false, the framework has gathered enough data and you can break out of the loop.
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.
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ImageProcessing Imports Leadtools.ImageProcessing.Color Imports Leadtools.Drawing Public Sub FeedGetInformationExample() 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 System.Windows.Forms.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() ' Show the information Console.WriteLine(info.ToString()) End Sub
using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Color; public void FeedGetInformationExample() { RasterCodecs codecs = new RasterCodecs(); string url = @"http://www.leadtools.com/images/page_graphics/leadlogo.png"; // 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 { System.Windows.Forms.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(); // Show the information Console.WriteLine(info.ToString()); }
// //public async Task FeedGetInformationExample() //{ // RasterCodecs codecs = new RasterCodecs(); // string url = @"http://www.leadtools.com/images/page_graphics/leadlogo.png"; // // 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.StartFeedGetInformation(true, 1); // const int bufferSize = 1024; // byte[] buffer = new byte[bufferSize]; // bool more; // do // { // int read = strm.Read(buffer, 0, bufferSize); // console.info("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.Dispose(); // } // CodecsImageInfo info = codecs.StopFeedGetInformation(); // // Clean up // codecs.Dispose(); // // Show the information // console.info(info.GetStringDescription()); //} //
using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Color; public async Task FeedGetInformationExample() { RasterCodecs codecs = new RasterCodecs(); string url = @"http://www.leadtools.com/images/page_graphics/leadlogo.png"; // 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.StartFeedGetInformation(true, 1); const int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; bool more; do { int read = strm.Read(buffer, 0, bufferSize); Debug.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.Dispose(); } CodecsImageInfo info = codecs.StopFeedGetInformation(); // Clean up codecs.Dispose(); // Show the information Debug.WriteLine(info.GetStringDescription()); }