GrayScaleToMultitone method (Main Control)

C++ Builder example

Delphi example

 

Builder Syntax

int GrayScaleToMultitone(unsigned uToneType, pCOLORREF pcrColor, unsigned uDistType, L_PRGBQUAD pGradient, unsigned uFlags);

Delphi Syntax

Function GrayScaleToMultitone (uToneType: L_UINT; pcrColor: pCOLORREF; uDistType: L_UINT; pGradient: L_PRGBQUAD; uFlags: L_UINT): L_INT;

Overview

Refer to Grayscale Images

Remarks

(Raster Pro and above toolkits.) Converts a grayscale bitmap into a colored one by mixing or replacing the original values of the pixels with one or more 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.

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:

(a)

If the bitmap is binary, call GrayScaleToMultitone with uToneType set to DT_MONOTONE, uDistType set to DT_LINEAR and the color you wish to use set in pColor. The IsGrayScale property will be checked by GrayScaleToDuotone to determine the kind of grayscale palette being used. If IsGrayScale is GRAY_ORDEREDINVERSE or GRAY_NOTORDERED, then the color passed in the pColor parameter to GrayScaleToMultitone will become the first color in the array generated by the toolkit, and the toolkit will create the second color in the array. The pColor array will be updated with these two colors.

 

If the IsGrayScale property was a value other than GRAY_ORDEREDINVERSE or GRAY_NOTORDERED, then the color passed in the pColor parameter to GrayScaleToMultitone will become the second color in the array generated by the toolkit, and the toolkit will create the first color in the array. The pColor parameter will be updated with these two colors.

(b)

If the bitmap is grayscale (not binary) call GrayScaleToMultitone with uDistType set to DT_LINEAR. The GrayScaleToMultitone method will take the color(s) passed to it in the pColor parameter and generate a 256 color gradient for each color.

 

(i)

If the uToneType is set to DT_DUOTONE, set two colors in the pColor parameter. The toolkit will create a 256 color array for each color. The pColor array will be updated with all 512 colors.

 

(ii)

If the uToneType is set to DT_TRITONE, set three colors in the pColor parameter. The toolkit will create a 256 color array for each color. The pColor array will be updated with all 768 colors.

 

(iii)

If the uToneType is set to DT_QUADTONE, set four colors in the pColor parameter. The toolkit will create a 256 color array for each color. The pColor array will be updated with all 1024 colors.

(c)

If the bitmap is not grayscale (it is color) call GrayScaleToMultitone with uDistType set to DT_LINEAR. The GrayScaleToMultitone method will take the color(s) passed to it in the pColor parameter and generate a 256 color gradient for each color. (See the expanded explanation in i, ii and iii of (b) above.) 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 GrayScaleToMultitone with uToneType set to DT_MONOTONE, uDistType set to DT_USERDEFINE and the two colors you wish to use in the pGradient parameter.

(b)

If the bitmap is grayscale (not binary) call GrayScaleToMultitone with uDistType set to DT_USERDEFINE.

 

(i)

If the uToneType is set to DT_DUOTONE, set 512 colors (256 for each basic color) in the pGradient parameter.

 

(ii)

If the uToneType is set to DT_TRITONE, set 768 colors (256 for each basic color) in the pGradient parameter.

 

(iii)

If the uToneType is set to DT_QUADTONE, set 1024 colors (256 for each basic color) in the pGradient parameter.

(c)

If the bitmap is not grayscale (it is color) call GrayScaleToMultitone with uDistType set to DT_USERDEFINE. (See the expanded explanation in i, ii and iii of (b) above.) These colors will be used to change only those pixels in the color image for which Red = Green = Blue.

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.

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.

See Also

Elements:

GrayScale method, IsGrayScale property, GrayScaleToDuotone method.

Topics:

Raster Images: Doing Color Expansion or Reduction

 

Using Color Values in LEADTOOLS