LEADTOOLS Color Conversion (Leadtools.ColorConversion assembly)

ConvertDirect(ConversionColorFormat,ConversionColorFormat,Byte[],Int32,Byte[],Int32,Int32,Int32,Int32,Int32) Method

Show in webframe
Example 





Format of the input data.
Format of the output data.
A byte array containing the input buffer.
Offset to the first byte of the srcBuffer data buffer.
A byte array that will hold the converted data.
Offset to the first byte of the destBuffer data buffer.
Width of pixels to be processed.
Height of pixels to be processed.
Each scanline in the input buffer is a multiple of inAlign bytes.
Each scan line in the output buffer is a multiple of outAlign bytes.
Converts image data in a buffer from one color conversion model to another directly using built in algorithms.
Syntax
public static void ConvertDirect( 
   ConversionColorFormat srcFormat,
   ConversionColorFormat destFormat,
   byte[] srcBuffer,
   int srcBufferOffset,
   byte[] destBuffer,
   int destBufferOffset,
   int width,
   int height,
   int inAlign,
   int outAlign
)
'Declaration
 
Public Overloads Shared Sub ConvertDirect( _
   ByVal srcFormat As ConversionColorFormat, _
   ByVal destFormat As ConversionColorFormat, _
   ByVal srcBuffer() As Byte, _
   ByVal srcBufferOffset As Integer, _
   ByVal destBuffer() As Byte, _
   ByVal destBufferOffset As Integer, _
   ByVal width As Integer, _
   ByVal height As Integer, _
   ByVal inAlign As Integer, _
   ByVal outAlign As Integer _
) 
'Usage
 
Dim srcFormat As ConversionColorFormat
Dim destFormat As ConversionColorFormat
Dim srcBuffer() As Byte
Dim srcBufferOffset As Integer
Dim destBuffer() As Byte
Dim destBufferOffset As Integer
Dim width As Integer
Dim height As Integer
Dim inAlign As Integer
Dim outAlign As Integer
 
RasterColorConverterEngine.ConvertDirect(srcFormat, destFormat, srcBuffer, srcBufferOffset, destBuffer, destBufferOffset, width, height, inAlign, outAlign)

            

            
public:
static void ConvertDirect( 
   ConversionColorFormat srcFormat,
   ConversionColorFormat destFormat,
   array<byte>^ srcBuffer,
   int srcBufferOffset,
   array<byte>^ destBuffer,
   int destBufferOffset,
   int width,
   int height,
   int inAlign,
   int outAlign
) 

Parameters

srcFormat
Format of the input data.
destFormat
Format of the output data.
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.
Remarks
There is no need to call the Start and Stop methods to initialize or stop the conversion engine.

Converting from any color space to YCCK color space is currently not supported.

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



To convert to the Yp41 type the input buffer length must be multiple of 8.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ColorConversion

Public Sub ConvertDirectExample()
   ' StartUp the ColorConversion.
   RasterColorConverterEngine.Startup()

   ' Rgb and Cmyk color buffer arrays
   Dim rgbColor(3) As Byte
   Dim cmykColor() As Byte = {100, 100, 100, 100}

   Try
      ' direct conversion using built in options
      ' The srcBufferOffset is an offset that indicates the beginning of the data in the sourec buffer.
      ' for example, if the data in the source buffer starts at byte 5, then this parameter = 5.
      ' in our case here, the image data starts at byte 0.
      ' The same thing applies to destBufferOffset.

      ' The cmykColor is a bytes array, you can pass it directly like this example,
      ' or you can pass an IntPtr pointer to the buffer.
      ' The same thing applies for rgbColor.
      RasterColorConverterEngine.ConvertDirect( _
         ConversionColorFormat.Cmyk, _
         ConversionColorFormat.Rgb, _
         cmykColor, _
         0, _
         rgbColor, _
         0, _
         1, _
         1, _
         0, _
         0)
   Catch ex As Exception
      MessageBox.Show(ex.Message)
   End Try
   '.
   '.
   '.
   ' use rgbColor as you need.

   ' Shutdown the ColorConversion.
   RasterColorConverterEngine.Shutdown()
End Sub
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ColorConversion;

public void ConvertDirectExample()
{
   // StartUp the ColorConversion.
   RasterColorConverterEngine.Startup();

   // Rgb and Cmyk color buffer arrays
   byte[] rgbColor = new byte[3];
   byte[] cmykColor = {100, 100, 100, 100};

   try
   {
      // direct conversion using built in options
      // The srcBufferOffset parameter is an offset to the start byte of the data in the source buffer.
      // For example, if the image data started at byte 5, then this variable should = 5.
      // in our case here, the image data starts at byte 0.
      // The same thing applies to destBufferOffset.

      // The cmykColor is a bytes array, you can pass it directly like this example,
      // or you can pass an IntPtr pointer to the buffer.
      // The same thing applies for rgbColor.
      RasterColorConverterEngine.ConvertDirect(
         ConversionColorFormat.Cmyk,
         ConversionColorFormat.Rgb,
         cmykColor,
         0,
         rgbColor,
         0,
         1,
         1,
         0,
         0);
   }
   catch(Exception ex)
   {
      MessageBox.Show(ex.Message);
   }

   //.
   //.
   //.
   // use rgbColor as you need.

   // Shutdown the ColorConversion.
   RasterColorConverterEngine.Shutdown();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ColorConversion;

public void ConvertDirectExample()
{
   // StartUp the ColorConversion.
   RasterColorConverterEngine.Startup();

   // Rgb and Cmyk color buffer arrays
   byte[] rgbColor = new byte[3];
   byte[] cmykColor = {100, 100, 100, 100};

   try
   {
      // direct conversion using built in options
      // The srcBufferOffset parameter is an offset to the start byte of the data in the source buffer.
      // For example, if the image data started at byte 5, then this variable should = 5.
      // in our case here, the image data starts at byte 0.
      // The same thing applies to destBufferOffset.

      // The cmykColor is a bytes array, you can pass it directly like this example,
      // or you can pass an IntPtr pointer to the buffer.
      // The same thing applies for rgbColor.
      RasterColorConverterEngine.ConvertDirect(
         ConversionColorFormat.Cmyk,
         ConversionColorFormat.Rgb,
         cmykColor,
         0,
         rgbColor,
         0,
         1,
         1,
         0,
         0);
   }
   catch(Exception)
   {
   }

   //.
   //.
   //.
   // use rgbColor as you need.

   // Shutdown the ColorConversion.
   RasterColorConverterEngine.Shutdown();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ColorConversion

      
Public Sub ConvertDirectExample()
   ' StartUp the ColorConversion.
   RasterColorConverterEngine.Startup()
   ' Rgb and Cmyk color buffer arrays
   Dim rgbColor As Byte() = New Byte(2){}
   Dim cmykColor As Byte() = {100, 100, 100, 100}

   Try
      ' direct conversion using built in options
      ' The srcBufferOffset parameter is an offset to the start byte of the data in the source buffer.
      ' For example, if the image data started at byte 5, then this variable should = 5.
      ' in our case here, the image data starts at byte 0.
      ' The same thing applies to destBufferOffset.

      ' The cmykColor is a bytes array, you can pass it directly like this example,
      ' or you can pass an IntPtr pointer to the buffer.
      ' The same thing applies for rgbColor.
      RasterColorConverterEngine.ConvertDirect(ConversionColorFormat.Cmyk, ConversionColorFormat.Rgb, cmykColor, 0, rgbColor, 0, 1, 1, 0, 0)
   Catch e1 As Exception
   End Try

   '.
   '.
   '.
   ' use rgbColor as you need.

   ' Shutdown the ColorConversion.
   RasterColorConverterEngine.Shutdown()
End Sub
Requirements

Target Platforms

See Also

Reference

RasterColorConverterEngine Class
RasterColorConverterEngine Members
Overload List
Alignment Parameters
Start Method
Stop Method
SetParameters Method
Convert
ConvertToImage

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.