←Select platform

Stop Method

Summary
Releases any color conversion engine resources used.
Syntax
C#
C++/CLI
Python
public void Stop() 
public: 
void Stop();  
def Stop(self): 
Remarks

The color conversion engine resources are initialized by calling the Start method. For each call to Start there must be a call to Stop. This method should be the last Color Conversion method called before calling the Shutdown method.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ColorConversion; 
 
 
       
public void StartupExample() 
{ 
   // Initialize the RasterCodecs class  
   RasterCodecs codecs = new RasterCodecs(); 
 
   // StartUp the ColorConversion.  
   RasterColorConverterEngine.Startup(); 
 
   // The input file name  
   string inputFileName = Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp"); 
 
   // load the input image as Bgr.  
   RasterImage bgrImage = codecs.Load(inputFileName, 24, CodecsLoadByteOrder.Bgr, 1, 1); 
 
   // Image buffer array  
   byte[] bgrBuffer = new byte[bgrImage.BytesPerLine * bgrImage.Height]; 
 
   bgrImage.Access(); 
   // get image buffer  
   for (int i = 0; i < bgrImage.Height; i++) 
      bgrImage.GetRow(i, bgrBuffer, i * bgrImage.BytesPerLine, bgrImage.BytesPerLine); 
   bgrImage.Release(); 
 
   // Initialize a new Converter object  
   RasterColorConverterEngine converter = new RasterColorConverterEngine(); 
 
   byte[] cmykBuffer = new byte[bgrImage.Height * bgrImage.Width * 4]; 
 
   try 
   { 
      // Start the color conversion  
      converter.Start(ConversionColorFormat.Bgr, ConversionColorFormat.Cmyk, null); 
 
      // convert the image buffer   
      converter.Convert(bgrBuffer, // input buffer  
         0, // offset from the beginning of the source buffer  
         cmykBuffer, // output buffer  
         0, // offset from the beginning of the destination buffer  
         bgrImage.Width, // pixels width  
         bgrImage.Height, // pixels height  
         bgrImage.BytesPerLine - (bgrImage.Width * (bgrImage.BitsPerPixel / 8)), 
         0); // 0 bytes align 
 
      // stop the conversion  
      converter.Stop(); 
 
      // Initialize an image to hold the converted buffer.  
      RasterImage cmykImage = new RasterImage(RasterMemoryFlags.Conventional, bgrImage.Width, bgrImage.Height, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, IntPtr.Zero, 0); 
 
      // Start the color conversion  
      converter.Start(ConversionColorFormat.Cmyk, ConversionColorFormat.Bgr, null); 
 
      // convert the image buffer  
      converter.ConvertToImage(cmykBuffer, // converted buffer  
         0,                // offset from the beginning of the source buffer  
         cmykImage,        // image to be save  
         bgrImage.Width,   // pixels width  
         bgrImage.Height,  // pixels height  
         0,                // 0 bytes align  
         bgrImage.BytesPerLine - (bgrImage.Width * (bgrImage.BitsPerPixel / 8))); 
 
      // stop the conversion  
      converter.Stop(); 
 
      // the output File Name.  
      string outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "ResultImage.bmp"); 
 
      // Save the result image.  
      codecs.Save(cmykImage, outputFileName, RasterImageFormat.Bmp, 24); 
 
      // dispose of the used images  
      bgrImage.Dispose(); 
      cmykImage.Dispose(); 
   } 
   catch (Exception ex) 
   { 
      Debug.WriteLine(ex.ToString()); 
   } 
 
   // Shutdown the ColorConversion.  
   RasterColorConverterEngine.Shutdown(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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

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