GrayScaleToDuotone method (Main Control)

C++ Builder example

Delphi example

 

Builder Syntax

int GrayScaleToDuotone(L_PRGBQUAD pNewColor, unsigned crColor, unsigned uFlags);

Delphi Syntax

Function GrayScaleToDuotone (pNewColor: L_PRGBQUAD; crColor: COLORREF; uFlags: L_UINT): L_INT;

Overview

Refer to Grayscale Images

Remarks

(Raster Pro and above toolkits) Converts the grayscale bitmap into a colored one by mixing or replacing the original values of the pixels with new colors.

This method was designed for use with grayscale bitmaps. If the bitmap being used is not grayscale, this method only affects those pixels or areas of the bitmap where Red=Green=Blue.

This method transforms the 8-bit grayscale bitmaps into colored 8-bit bitmaps (Palette), meanwhile the 12-bit and 16-bit grayscale bitmaps are transformed into a 48-bit colored bitmap.

Monotone conversion is possible by setting uFlags to DT_REPLACE, which clears the palette.

This method gives you the option of having the toolkit generate the array of colors to use or creating the array of colors to use yourself.

To have the toolkit generate the array of colors:

Pass the color to use for generating the array of gradient colors in the crColor parameter.

(a)

If the bitmap is binary, the IsGrayScale property is checked by the GrayScaleToDuotone method to determine the kind of grayscale palette being used. If the IsGrayScale property is GRAY_ORDEREDINVERSE or GRAY_NOTORDERED, then the color passed in the crColor parameter to GrayScaleToDuotone will become the first color in the array generated by the toolkit, pNewColor[0], and the toolkit will create the second color in the array pNewColor[1].

 

If the IsGrayScale property contains a value other than GRAY_ORDEREDINVERSE or GRAY_NOTORDERED, then the color passed in the crColor parameter to GrayScaleToDuotone will become the second color in the array generated by the toolkit, pNewColor[1], and the toolkit will create the first color in the array pNewColor[0].

(b)

If the bitmap is grayscale (not binary) the GrayScaleToDuotone will take the color passed to it in the crColor parameter and generate a 256 color gradient in pNewColor.

(c)

If the bitmap is not grayscale (it is color) then the GrayScaleToDuotone method will use the color passed to it in the crColor parameter and generate a 256 color gradient in pNewColor. These colors will be used to change only those pixels in the color image for which Red = Green = Blue.

To use a user-defined array of colors:

(a)

If the bitmap is binary, call GrayScaleToDuotone with the two colors you wish to use in the pNewColor parameter.

(b)

If the bitmap is grayscale (not binary) call GrayScaleToDuotone with the 256 colors you wish to use in the pNewColor parameter.

(c)

If the bitmap is not grayscale (it is color) call GrayScaleToDuotone with the 256 colors you wish to use in the pNewColor parameter. These colors will be used to change only those pixels in the color image for which Red = Green = Blue.

This method supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.

This method does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this method.

See Also

Elements:

GrayScale method, IsGrayScale property, GrayScaleToMultitone method.

Topics:

Raster Images: Doing Color Expansion or Reduction

 

Using Color Values in LEADTOOLS