Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
LBitmap::SelectiveColor
#include "ltwrappr.h"
virtual L_INT LBitmap::SelectiveColor (pSelClr, uFlags = 0)
pSELCLR pSelClr; |
/* pointer a structure that contains the selected colors definition */ |
L_UINT32 uFlags; |
/* flags */ |
Changes the color of a bitmap by altering the definitions of one or more colors used by the bitmap.
Parameter |
Description |
pSelClr |
Pointer to a SELCLR structure that contains the selected colors along with the CMYK values for each. |
uFlags |
Reserved for future use. Must be 0. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
Before you call the LBitmap::SelectiveColor function, you need to initialize the size and all remaining fields of the SELCLR structure.
Selected colors are the additive colors (Red, Green and Blue), the subtractive colors (Cyan, Magenta and Yellow), the highlights (White), the midtones (Neutral) and the shadows (Black). Each of those "Selected Colors" has information about the percentages of cyan, magenta, yellow and black that constructs that selective color. Each unique pixels color can be defined as using some certain percentage of CMYK values. By changing the percentage of CMYK values for a "selected color", all colors related to that "selected color" would change also. For example, you can decrease the Magenta percentage from the "Blue selected color" to change a blue color to a color that is more similar to Cyan. Also you can increase the Yellow percentage from the "Magenta selected color" to change magenta color to a color that is more similar to Red.
You control the percentage of CMYK for each of the selected colors using the selClrs member of the SELCLR structure. The SELCLRINF structure used in selClrs has four members, cCyan, cMagenta, cYellow and cBlack. Each takes a value from 100 to 100. Negative values for any of these members decreases the percentage of that color, whereas positive values increases the percentage of that color. If cCyan = -100 it means no cyan will be used, whereas if cCyan = 100 it means the full percentage of cyan will be used. If a value is out of range, a negative value goes to -100 and a positive value goes to 100.
Pixel colors are changed based on HSV color space. For example, if you alter the values for selClrs[SELCLR_RED], then if a pixel value is within the RED range of the Hue scale, it is considered red and is changed using the settings in selClrs[SELCLR_RED].
This function supports 48 and 64-bit color images. It does not support grayscale images. Support for 48 and 64-bit color images is available only in the Document/Medical toolkits.
If the bitmap has a region, the effect will be applied on the region only.
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. |
See Also
Example
This example loads a bitmap and applies selective color to the image
L_INT LBitmap__SelectiveColorExample(LAnimationWindow * LAniWnd) { SELCLR selClr; /* Variable to be used in the function */ // Initialize selClr to zeros. memset (&selClr, 0, sizeof(SELCLR)); /* Manipulate values */ selClr.uStructSize = sizeof (SELCLR); selClr.selClrs[SELCLR_RED].cCyan = -100; // Change the "Red selected color" selClr.selClrs[SELCLR_YELLOW].cCyan = 34; // Change the "Yellow selected color" selClr.selClrs[SELCLR_YELLOW].cMagenta = 100; selClr.selClrs[SELCLR_YELLOW].cYellow = 40; selClr.selClrs[SELCLR_GREEN].cBlack = 100; // Change the "Green selected color" selClr.selClrs[SELCLR_NEUTRAL].cCyan = -65; // Change the "neutral selected color" selClr.selClrs[SELCLR_NEUTRAL].cMagenta = -39; selClr.selClrs[SELCLR_NEUTRAL].cYellow = 63; // Call the function return LAniWnd->SelectiveColor (&selClr); }