Leadtools.ColorConversion Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.5.7
WhitePoint Property
See Also  Example
Leadtools.ColorConversion Namespace > ConversionParameters Class : WhitePoint Property




Gets or sets the white point properties.

Syntax

Visual Basic (Declaration) 
Public Property WhitePoint As ConversionWhitePoint
Visual Basic (Usage)Copy Code
Dim instance As ConversionParameters
Dim value As ConversionWhitePoint
 
instance.WhitePoint = value
 
value = instance.WhitePoint
C# 
public ConversionWhitePoint WhitePoint {get; set;}
Managed Extensions for C++ 
public: __property ConversionWhitePoint get_WhitePoint();
public: __property void set_WhitePoint( 
   ConversionWhitePoint value
);
C++/CLI 
public:
property ConversionWhitePoint WhitePoint {
   ConversionWhitePoint get();
   void set (ConversionWhitePoint value);
}

Return Value

The white point properties.

Example

This example will converts RGB to CMYK using built-in conversion.

Visual BasicCopy Code
Public Sub WhitePointExampleExample()
    ' Initialize the RasterCodecs class
    RasterCodecs.Startup()
    Dim codecs As RasterCodecs = New RasterCodecs

    ' StartUp the ColorConversion.
    RasterColorConverter.Startup()

    ' The input file name
    Dim inputFileName As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image1.cmp"

    ' load the input image as Rgb.
    Dim rgbImage As RasterImage = codecs.Load(inputFileName, 24, CodecsLoadByteOrder.Rgb, 1, 1)

    ' Image buffer array
    Dim rgbBuffer(rgbImage.BytesPerLine * rgbImage.Height) As Byte

    ' get image buffer
    For i As Integer = 0 To rgbImage.Height - 1
        rgbImage.GetRow(i, rgbBuffer, (i * rgbImage.BytesPerLine), rgbImage.BytesPerLine)
    Next
    ' Initialize the Cmyk buffer array
    Dim cmykBuffer(CInt(rgbImage.Height * rgbImage.Width * 4)) As Byte

    ' Initialize a new Converter object
    Dim converter As New RasterColorConverter

    ' Initialize a new ConversionParameters new class object.
    Dim convParams As ConversionParameters = New ConversionParameters

    ' Initialize the WhitePoint property class.
    Dim whitePoint As ConversionWhitePoint = ConversionWhitePoint.Empty

    ' Set the WhitePoint property.
    whitePoint.WhitePoint = ConversionWhitePointType.D50

    ' Set the XWhite property.
    whitePoint.XWhite = 0

    ' Set the YWhite property.
    whitePoint.YWhite = 0
    convParams.WhitePoint = whitePoint

    ' Set the Quantization property.
    convParams.Quantization = 8

    ' Set the Method property.
    convParams.Method = ConversionMethodFlags.UseBuiltIn

    ' Set the ActiveMethod property.
    convParams.ActiveMethod = ConversionMethodFlags.UseBuiltIn

    ' Set GcrLevel property.
    Dim cmykParameters As New ConversionCmykParameters()
    cmykParameters.GcrLevel = 150
    convParams.CmykParameters = cmykParameters

    Try
        ' Start the ColorConversion.
        converter.Start(ConversionColorFormat.Rgb, ConversionColorFormat.Cmyk, convParams)

        ' Convert Rgb to CMYK.
        converter.Convert(rgbBuffer, _
            0, _
            cmykBuffer, _
            0, _
            rgbImage.Width, _
            rgbImage.Height, _
            CInt(rgbImage.BytesPerLine - (rgbImage.Width * (rgbImage.BitsPerPixel / 8))), _
            0)

        ' Stop the ColorConversion.
        converter.Stop()

        ' Initialize an image to hold the converted buffer.
        Dim cmykImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, rgbImage.Width, rgbImage.Height, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, Nothing, IntPtr.Zero, 0)

        ' Start the color conversion
        converter.Start(ConversionColorFormat.Cmyk, ConversionColorFormat.Bgr, convParams)

        ' convert the image buffer
        converter.ConvertToImage(cmykBuffer, _
           0, _
           cmykImage, _
           rgbImage.Width, _
           rgbImage.Height, _
           0, _
           CInt(rgbImage.BytesPerLine - (rgbImage.Width * (rgbImage.BitsPerPixel / 8))))

        ' stop the conversion
        converter.Stop()

        ' the output File Name.
        Dim outputFileName As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\ResultImage.bmp"

        ' Save the result image.
        codecs.Save(cmykImage, outputFileName, RasterImageFormat.Bmp, 24)

        ' dispose the used images
        rgbImage.Dispose()
        cmykImage.Dispose()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
    ' Shutdown the ColorConversion.
    RasterColorConverter.Shutdown()
    RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void WhitePointPropertyExample() 

   // Initialize the RasterCodecs class 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // StartUp the ColorConversion. 
   RasterColorConverter.Startup(); 
 
   // The input file name 
   string inputFileName = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image1.cmp"; 
 
   // load the input image as Rgb. 
   RasterImage rgbImage = codecs.Load(inputFileName, 24, CodecsLoadByteOrder.Rgb, 1, 1); 
 
   // Image buffer array 
   byte[] rgbBuffer = new byte[rgbImage.BytesPerLine * rgbImage.Height]; 
 
   // get image buffer 
   for(int i = 0; i < rgbImage.Height; i ++) 
       rgbImage.GetRow(i, rgbBuffer, i * rgbImage.BytesPerLine, rgbImage.BytesPerLine); 
 
   // Initialize the Cmyk buffer array 
   byte[] cmykBuffer = new byte[rgbImage.Height * rgbImage.Width * 4]; 
 
   // Initialize a new Converter object 
   RasterColorConverter converter = new RasterColorConverter(); 
 
   // Initialize a new ConversionParameters new class object. 
   ConversionParameters convParams = new ConversionParameters(); 
 
   // Initialize the WhitePoint property class. 
   ConversionWhitePoint whitePoint = ConversionWhitePoint.Empty; 
 
   // Set the WhitePoint property. 
   whitePoint.WhitePoint = ConversionWhitePointType.D50; 
 
   // Set the XWhite property. 
   whitePoint.XWhite = 0; 
 
   // Set the YWhite property. 
   whitePoint.YWhite = 0; 
   convParams.WhitePoint = whitePoint; 
 
   // Set the Quantization property. 
   convParams.Quantization = 8; 
 
   // Set the Method property. 
   convParams.Method = ConversionMethodFlags.UseBuiltIn; 
 
   // Set the ActiveMethod property. 
   convParams.ActiveMethod = ConversionMethodFlags.UseBuiltIn; 
 
   // Set GcrLevel property. 
   ConversionCmykParameters cmykParameters = new ConversionCmykParameters(); 
   cmykParameters.GcrLevel = 150; 
   convParams.CmykParameters = cmykParameters; 
 
   // Initialize an image to hold the converted buffer. 
   RasterImage cmykImage = null; 
   try 
   { 
      // Start the ColorConversion. 
      converter.Start(ConversionColorFormat.Rgb, ConversionColorFormat.Cmyk, convParams); 
 
      // Convert Rgb to CMYK. 
      converter.Convert( 
          rgbBuffer,  
          0,  
          cmykBuffer,  
          0,  
          rgbImage.Width,  
          rgbImage.Height, 
          rgbImage.BytesPerLine - (rgbImage.Width * (rgbImage.BitsPerPixel / 8)), 
          0); 
 
      // Stop the ColorConversion. 
      converter.Stop(); 
 
      // Initialize labImage. 
      cmykImage = new RasterImage(RasterMemoryFlags.Conventional, rgbImage.Width, rgbImage.Height, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, IntPtr.Zero, 0); 
 
      // Start the color conversion 
      converter.Start(ConversionColorFormat.Cmyk, ConversionColorFormat.Bgr, convParams); 
 
      // convert the image buffer 
      converter.ConvertToImage(cmykBuffer, // converted buffer 
         0, // offset to the beginning of source buffer 
         cmykImage, // image to be save 
         rgbImage.Width, // pixels width 
         rgbImage.Height, // pixels height 
         0, // 0 bytes align 
         rgbImage.BytesPerLine - (rgbImage.Width * (rgbImage.BitsPerPixel / 8))); 
 
      // stop the conversion 
      converter.Stop(); 
 
      // the output File Name. 
      string outputFileName = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\ResultImage.bmp"; 
 
      // Save the result image. 
      codecs.Save(cmykImage, outputFileName, RasterImageFormat.Bmp, 24); 
 
      // dispose the used images 
      rgbImage.Dispose(); 
      cmykImage.Dispose(); 
   } 
   catch(Exception ex) 
   { 
      MessageBox.Show(ex.Message); 
   } 
   // Shutdown the ColorConversion. 
   RasterColorConverter.Shutdown(); 
   RasterCodecs.Shutdown(); 
}

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also