←Select platform

Convert(IntPtr,long,IntPtr,long,int,int,int,int) Method

Summary
Converts image data in a buffer from one color conversion model to another.
Syntax
C#
C++/CLI
Python
public void Convert( 
   IntPtr srcBuffer, 
   long srcBufferOffset, 
   IntPtr destBuffer, 
   long destBufferOffset, 
   int width, 
   int height, 
   int inAlign, 
   int outAlign 
) 
public: 
void Convert(  
   IntPtr srcBuffer, 
   int64 srcBufferOffset, 
   IntPtr destBuffer, 
   int64 destBufferOffset, 
   int width, 
   int height, 
   int inAlign, 
   int outAlign 
)  

Parameters

srcBuffer
A pointer to a buffer containing the input data.

srcBufferOffset
Offset to the first byte of the  srcBuffer data buffer.

destBuffer
A pointer to a buffer that will hold the converted data.

destBufferOffset
Offset to the first byte of the  destBuffer data buffer.

width
Width of pixels to be processed.

height
Height of pixels to be processed.

inAlign
Each scanline in the input buffer is a multiple of inAlign bytes.

outAlign
Each scan line in the output buffer is a multiple of outAlign bytes.

Remarks

Conversion is done by setting the active method value specified in ActiveMethod property. To change the active method, use SetParameters method. To convert to the Y41P type the input image width must be multiple of 8

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ColorConversion; 
 
using Leadtools.ImageProcessing; 
 
public void StartupExample() 
{ 
   // StartUp the ColorConversion.  
   RasterColorConverterEngine.Startup(); 
 
   // Input file name  
   string inputFileName = Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp"); 
 
   // Load the input image as Bgr 
   using (RasterCodecs codecs = new RasterCodecs()) 
   using (RasterImage bgrImage = codecs.Load(inputFileName, 24, CodecsLoadByteOrder.Bgr, 1, 1)) 
   { 
      // BGR buffer  
      byte[] bgrBuffer = new byte[bgrImage.BytesPerLine * bgrImage.Height]; 
      bgrImage.Access(); 
      bgrImage.GetRow(0, bgrBuffer, 0, bgrImage.BytesPerLine * bgrImage.Height); 
      bgrImage.Release(); 
 
      // CMYK buffer 
      byte[] cmykBuffer = new byte[bgrImage.Height * bgrImage.Width * 4]; 
 
      // Start the color conversion  
      RasterColorConverterEngine rasterColorConverterEngine = new RasterColorConverterEngine(); 
      rasterColorConverterEngine.Start(ConversionColorFormat.Bgr, ConversionColorFormat.Cmyk, null); 
      rasterColorConverterEngine.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)), // Scanline alignment for input buffer 
         0); // Scanline alignment for output buffer 
      rasterColorConverterEngine.Stop(); 
   } 
 
   // Shutdown the ColorConversion.  
   RasterColorConverterEngine.Shutdown(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 

For more information about Alignment Parameters, refer to Alignment Parameters.

Requirements

Target Platforms

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

Leadtools.ColorConversion Assembly

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