←Select platform

CmykParameters Property

Summary
Gets or sets the CMYK conversion properties.
Syntax
C#
C++/CLI
Python
public ConversionCmykParameters CmykParameters { get; set; } 
public: 
property ConversionCmykParameters CmykParameters { 
   ConversionCmykParameters get(); 
   void set (    ConversionCmykParameters ); 
} 
CmykParameters # get and set (ConversionParameters) 

Property Value

A ConversionCmykParameters structure that contains the CIELab conversion properties.

Remarks

The CMYK conversion properties. If this property value is null(Nothing), default values are assumed.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ColorConversion; 
 
using Leadtools.ImageProcessing; 
 
public string builtInOutputFile = Path.Combine(LEAD_VARS.ImagesDir, "ColorConversion", "BuiltInCmykToRgb.bmp"); 
public string parametersOutputFile = Path.Combine(LEAD_VARS.ImagesDir, "ColorConversion", "ParametersCmykToRgb.bmp"); 
 
public void SetParametersExample() 
{ 
   // StartUp the Color Conversion Engine 
   RasterColorConverterEngine.Startup(); 
 
   // Initialize a new Converter object 
   RasterColorConverterEngine colorConverterEngine = new RasterColorConverterEngine(); 
 
   // 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)) 
   { 
      // Image width and height 
      int width = bgrImage.Width; 
      int height = bgrImage.Height; 
 
      // Get BGR buffer 
      byte[] bgrBuffer = new byte[bgrImage.BytesPerLine * bgrImage.Height]; 
      bgrImage.Access(); 
      bgrImage.GetRow(0, bgrBuffer, 0, bgrImage.BytesPerLine * bgrImage.Height); 
      bgrImage.Release(); 
 
      // Convert to CMYK  
      byte[] cmykBuffer = new byte[bgrImage.Height * bgrImage.Width * 4]; 
      colorConverterEngine.Start(ConversionColorFormat.Bgr, ConversionColorFormat.Cmyk, null); 
      colorConverterEngine.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 
      colorConverterEngine.Stop(); 
 
      // Set White Point and CMYK parameters for conversion with built-in method 
      ConversionParameters convParams = new ConversionParameters(); 
      convParams.Method = ConversionMethodFlags.UseBuiltIn | ConversionMethodFlags.UseIcc; 
      convParams.ActiveMethod = ConversionMethodFlags.UseBuiltIn; 
      convParams.WhitePoint = new ConversionWhitePoint() { WhitePoint = ConversionWhitePointType.D50 }; 
      convParams.CmykParameters = new ConversionCmykParameters() { GcrLevel = 150 }; 
 
      // Convert to RGB 
      byte[] rgbBuffer = new byte[cmykBuffer.Length - cmykBuffer.Length / 4]; 
      colorConverterEngine.Start(ConversionColorFormat.Cmyk, ConversionColorFormat.Rgb, convParams); 
      colorConverterEngine.Convert(cmykBuffer, 
         0, 
         rgbBuffer, 
         0, 
         width, 
         height, 
         0, 
         bgrImage.BytesPerLine - (bgrImage.Width * (bgrImage.BitsPerPixel / 8))); 
 
      // Save output RGB image 
      using(RasterImage outputRgbImage = new RasterImage(RasterMemoryFlags.Conventional, width, height, 24, RasterByteOrder.Rgb, RasterViewPerspective.TopLeft, null, rgbBuffer, rgbBuffer.Length)) 
         codecs.Save(outputRgbImage, builtInOutputFile, RasterImageFormat.Bmp, 24); 
 
      // Change conversion parameters 
      convParams.Method = ConversionMethodFlags.ChangeActiveMethod | ConversionMethodFlags.ChangeCmyk; 
      convParams.ActiveMethod = ConversionMethodFlags.UseIcc; 
      convParams.CmykParameters = new ConversionCmykParameters() { GcrLevel = 150, Mask = ConversionCmykMask.Gcr }; 
 
      // Update and convert using the new conversion parameters 
      colorConverterEngine.SetParameters(convParams); 
      colorConverterEngine.Convert(cmykBuffer, 0, rgbBuffer, 0, width, height, 0, 0); 
      colorConverterEngine.Stop(); 
 
      // Save output RGB image 
      using (RasterImage outputRgbImage = new RasterImage(RasterMemoryFlags.Conventional, width, height, 24, RasterByteOrder.Rgb, RasterViewPerspective.TopLeft, null, rgbBuffer, rgbBuffer.Length)) 
         codecs.Save(outputRgbImage, parametersOutputFile, RasterImageFormat.Bmp, 24); 
   } 
 
   // Dispose of color converter engine 
   colorConverterEngine.Dispose(); 
 
   // Shutdown the RasterColor Color Converter Engine 
   RasterColorConverterEngine.Shutdown(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.10.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.