L_LTIMGCLR_API L_INT L_SelectiveColorBitmap(pBitmap, pSelClr, uFlags)
Changes the color of a bitmap by altering the definitions of one or more colors used by the bitmap.
Pointer to the bitmap handle.
Pointer to a SELCLR structure that contains the selected colors along with the CMYK values for each.
Reserved for future use. Must be 0.
|SUCCESS||The function was successful.|
|< 1||An error occurred. Refer to Return Codes.|
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.
Before you call the L_SelectiveColorBitmap 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].
To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.
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 in the Document and Medical Imaging toolkits.
If the bitmap has a region, the effect will be applied on the region only.
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
Win32, x64, Linux.
This example loads a bitmap and applies selective color to the image.
BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */
SELCLR selClr; /* Variable to be used in the function */
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("cannon.jpg")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
// 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
nRet = L_SelectiveColorBitmap (&LeadBitmap, &selClr, 0);
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL);
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries