←Select platform

StopFeedLoad Method

Summary
Ends a file-load process in which you control the input stream.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public RasterImage StopFeedLoad() 
- (nullable LTRasterImage *)stopFeedLoad:(NSError **)error 
public RasterImage stopFeedLoad() 
public: 
RasterImage^ StopFeedLoad();  
def StopFeedLoad(self): 

Return Value

The image loaded by the FeedLoad process.

Remarks

This cleans up all the variables and buffers allocated by the StartFeedLoad and FeedLoad methods and resets all internal variables to their default settings.

You must call this method to complete a file load that was started with StartFeedLoad.

If you call this method before supplying the complete file, it will successfully clean up the process, but will throw a file-read exception. You should trap the error if the load is canceled purposely.

For a description of how the methods relate to each other, refer to StartFeedLoad.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
public void FeedLoadExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   codecs.CancelFeedLoad(); 
 
   string url = @"https://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); 
         Debug.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:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.