public void Convert(byte[] srcBuffer,int srcBufferOffset,byte[] destBuffer,int destBufferOffset,int width,int height,int inAlign,int outAlign)
srcBuffer
A byte array containing the input buffer.
srcBufferOffset
Offset to the first byte of the srcBuffer data buffer.
destBuffer
A byte array 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.
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 Yp41 type the input image width must be multiple of 8
using Leadtools;using Leadtools.Codecs;using Leadtools.ColorConversion;public void StartupExample(){// Initialize the RasterCodecs classRasterCodecs codecs = new RasterCodecs();// StartUp the ColorConversion.RasterColorConverterEngine.Startup();// The input file namestring 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 arraybyte[] bgrBuffer = new byte[bgrImage.BytesPerLine * bgrImage.Height];bgrImage.Access();// get image bufferfor (int i = 0; i < bgrImage.Height; i++)bgrImage.GetRow(i, bgrBuffer, i * bgrImage.BytesPerLine, bgrImage.BytesPerLine);bgrImage.Release();// Initialize a new Converter objectRasterColorConverterEngine converter = new RasterColorConverterEngine();byte[] cmykBuffer = new byte[bgrImage.Height * bgrImage.Width * 4];try{// Start the color conversionconverter.Start(ConversionColorFormat.Bgr, ConversionColorFormat.Cmyk, null);// convert the image bufferconverter.Convert(bgrBuffer, // input buffer0, // offset from the beginning of the source buffercmykBuffer, // output buffer0, // offset from the beginning of the destination bufferbgrImage.Width, // pixels widthbgrImage.Height, // pixels heightbgrImage.BytesPerLine - (bgrImage.Width * (bgrImage.BitsPerPixel / 8)),0); // 0 bytes align// stop the conversionconverter.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 conversionconverter.Start(ConversionColorFormat.Cmyk, ConversionColorFormat.Bgr, null);// convert the image bufferconverter.ConvertToImage(cmykBuffer, // converted buffer0, // offset from the beginning of the source buffercmykImage, // image to be savebgrImage.Width, // pixels widthbgrImage.Height, // pixels height0, // 0 bytes alignbgrImage.BytesPerLine - (bgrImage.Width * (bgrImage.BitsPerPixel / 8)));// stop the conversionconverter.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 imagesbgrImage.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";}
For more information about Alignment Parameters, refer to Alignment Parameters.