Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.24
LEADTOOLS Raster imaging C++ Class library help

LBitmap::GrayScaleToDuotone

Show in webframe

#include "ltwrappr.h"

virtual L_INT LBitmap::GrayScaleToDuotone (pNewColor, crColor, uFlags)

LPRGBQUAD pNewColor;

/* pointer to an array of colors */

COLORREF crColor;

/* color */

L_UINT uFlags;

/* flag that indicates whether colors will be mixed or replaced */

Converts the grayscale bitmap into a colored one by mixing or replacing the original values of the pixels with new colors.

Parameter

Description

pNewColor

Pointer to an RGBQUAD structure that specifies an array of colors that will be mixed with the original gray values. If this parameter is set to NULL, the crColor parameter must contain a valid color. Pass NULL when you want the function to create the array of colors, two colors when replacing both colors in a binary image, or 256 colors when using a custom array of colors.

crColor

An RGB color that will be used to create an array of colors internally. This parameter is used when the pNewColor structure is set to NULL. This parameter is ignored if the pNewColor value is something other than NULL.

uFlags

Flag that indicates whether colors will be mixed or replaced.  Possible values are:

 

Value

Meaning

 

DT_MIX

[0x0000] Mix the old colors with the new ones

 

DT_REPLACE

[0x0001] Replace the old colors with the new ones

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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

This function 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 function 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 LBitmapBase::IsGrayScale function is called by LBitmap::GrayScaleToDuotone to determine the kind of grayscale palette being used. If LBitmapBase::IsGrayScale returns GRAY_ORDEREDINVERSE or GRAY_NOTORDERED, then the color passed in the crColor parameter to LBitmap::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 LBitmapBase::IsGrayScale returns a value other than GRAY_ORDEREDINVERSE or GRAY_NOTORDERED, then the color passed in the crColor parameter to LBitmap::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 LBitmap::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 LBitmap::GrayScaleToDuotone 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 LBitmap::GrayScaleToDuotone with the two colors you wish to use in the pNewColor parameter.

(b)

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

(c)

If the bitmap is not grayscale (it is color) call LBitmap::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 function 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 function 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 function.

This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.

Required DLLs and Libraries

LTIMGCLR

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64.

See Also

Functions:

LBitmapBase::GrayScale, LBitmapBase::IsGrayScale, LBitmap::GrayScaleToMultitone

Topics:

Raster Image Functions: Doing Color Expansion or Reduction

 

Grayscale Images

 

Using Color Values in LEADTOOLS

 

Color Halftones and Halftone Images

 

Raster Image Functions: Working with Color Halftones, Halftones, and Grayscale Images

Example

This example loads a bitmap and converts it to a Duotone.

L_INT LBitmap__GrayScaleToDuotoneExample(LAnimationWindow * LAniWnd) 
{
   L_INT nRet;
   COLORREF crColor;                  /* New Color */
  /* Change the bitmap to grayscale bitmap */
   nRet =LAniWnd->GrayScale ( 8);
   if(nRet !=SUCCESS)
      return nRet;
   /* The new color is Red */
   crColor = RGB(255, 0, 0); 
   /* Apply duotone conversion*/
   nRet =LAniWnd->GrayScaleToDuotone(NULL, crColor,  DT_REPLACE);
   if(nRet !=SUCCESS)
      return nRet;
   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.