LBitmap::GrayScaleToMultitone

#include "ltwrappr.h"

virtual L_INT LBitmap::GrayScaleToMultitone (uToneType, uDistType, pColor, pGradient, uFlags)

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

Parameters

L_UINT uToneType

Flag that indicates the number of colors to add to the grayscale bitmap. Possible values are:

Value Meaning
DT_MONOTONE [0x0000] Add one color.
DT_DUOTONE [0x0001] Add two colors.
DT_TRITONE [0x0002] Add three colors.
DT_QUADTONE [0x0003] Add four colors.

L_UINT uDistType

Flag that indicates the source of the colors to be added to the bitmap. Possible values are:

Value Meaning
DT_LINEAR [0] Use the linear gradient from dark to light, generated by the toolkit. If this flag is set, LEADTOOLS will ignore the pGradient parameter and update the pColor parameter with an array of colors generated by the toolkit.
DT_USERDEFINE [1] Use the user-defined gradient in the pGradient parameter.

LPCOLORREF pColor

Pointer to an array of RGB colors, that will be added to the grayscale bitmap. This parameter is ignored when the uDistType parameter is set to DT_USERDEFINE. If the toolkit is generating the gradient colors, the user sets the desired base color(s) in this parameter when LBitmap::GrayScaleToMultitone is called. The number of entries in the array depends on the value of uToneType: 1 for DT_MONOTONE, 2 for DT_DUOTONE, 3 for DT_TRITONE, 4 for DT_QUADTONE. When the toolkit generates the array of gradient colors, this parameter will be updated with that array.

LPRGBQUAD * pGradient

Pointer to a user-defined array of palette entries that will hold the set of color shade gradients. This parameter is used when the uDistType parameter is set to DT_USERDEFINE.

The number of entries in this array should be 256 entries for each TONE.

L_UINT uFlags

Flag used to determine whether the new colors replace the old colors, or whether the new colors will be mixed with the old colors. 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

Value Meaning
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.

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:

To use a user-defined array of colors:

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

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example applies Duotone conversion to it.

L_INT LBitmap__GrayScaleToMultitoneExample(LAnimationWindow *BitmapWindow)  
{ 
   L_INT nRet; 
   COLORREF     crColor[2];        /* New Color */ 
 
   /* Change the bitmap to grayscale bitmap*/ 
   nRet =BitmapWindow->GrayScale (8); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /* The new colors */ 
   crColor[0] = RGB(255, 255, 0);  
   crColor[1] = RGB(255, 0, 0);  
 
   /* Apply Multitone conversion */ 
   nRet =BitmapWindow->GrayScaleToMultitone(DT_DUOTONE,DT_LINEAR, crColor, NULL, DT_REPLACE); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 

Help Version 21.0.2021.4.8
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help