Converts the grayscale bitmap into a colored one by mixing or replacing the original values of the pixels with new colors.
#include "ltwrappr.h"
virtual L_INT LBitmap::GrayScaleToDuotone (pNewColor, crColor, uFlags)
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.
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.
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 |
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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.
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].
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.
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:
If the bitmap is binary, call LBitmap::GrayScaleToDuotone with the two colors you wish to use in the pNewColor parameter.
If the bitmap is grayscale (not binary) call LBitmap::GrayScaleToDuotone with the 256 colors you wish to use in the pNewColor parameter.
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.
Gray Scale to Duotone Function - Before
Gray Scale to Duotone Function - After
View additional platform support for this Gray Scale to Duotone function.
Win32, x64.
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;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document