Public Sub WhitePointExampleExample()
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs
RasterColorConverter.Startup()
Dim inputFileName As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image1.cmp"
Dim rgbImage As RasterImage = codecs.Load(inputFileName, 24, CodecsLoadByteOrder.Rgb, 1, 1)
Dim rgbBuffer(rgbImage.BytesPerLine * rgbImage.Height) As Byte
For i As Integer = 0 To rgbImage.Height - 1
rgbImage.GetRow(i, rgbBuffer, (i * rgbImage.BytesPerLine), rgbImage.BytesPerLine)
Next
Dim cmykBuffer(CInt(rgbImage.Height * rgbImage.Width * 4)) As Byte
Dim converter As New RasterColorConverter
Dim convParams As ConversionParameters = New ConversionParameters
Dim whitePoint As ConversionWhitePoint = ConversionWhitePoint.Empty
whitePoint.WhitePoint = ConversionWhitePointType.D50
whitePoint.XWhite = 0
whitePoint.YWhite = 0
convParams.WhitePoint = whitePoint
convParams.Quantization = 8
convParams.Method = ConversionMethodFlags.UseBuiltIn
convParams.ActiveMethod = ConversionMethodFlags.UseBuiltIn
Dim cmykParameters As New ConversionCmykParameters()
cmykParameters.GcrLevel = 150
convParams.CmykParameters = cmykParameters
Try
converter.Start(ConversionColorFormat.Rgb, ConversionColorFormat.Cmyk, convParams)
converter.Convert(rgbBuffer, _
0, _
cmykBuffer, _
0, _
rgbImage.Width, _
rgbImage.Height, _
CInt(rgbImage.BytesPerLine - (rgbImage.Width * (rgbImage.BitsPerPixel / 8))), _
0)
converter.Stop()
Dim cmykImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, rgbImage.Width, rgbImage.Height, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, Nothing, IntPtr.Zero, 0)
converter.Start(ConversionColorFormat.Cmyk, ConversionColorFormat.Bgr, convParams)
converter.ConvertToImage(cmykBuffer, _
0, _
cmykImage, _
rgbImage.Width, _
rgbImage.Height, _
0, _
CInt(rgbImage.BytesPerLine - (rgbImage.Width * (rgbImage.BitsPerPixel / 8))))
converter.Stop()
Dim outputFileName As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\ResultImage.bmp"
codecs.Save(cmykImage, outputFileName, RasterImageFormat.Bmp, 24)
rgbImage.Dispose()
cmykImage.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
RasterColorConverter.Shutdown()
RasterCodecs.Shutdown()
End Sub |