L_SelectiveColorBitmap

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_SelectiveColorBitmap(pBitmap, pSelClr)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

pSELCLR pSelClr;

/* pointer to a SELCLR structure that contains the selected color’s definition */

Changes the color of a bitmap by altering the definitions of one or more colors used by the bitmap. This function is available in the Raster Pro and above toolkits.

Parameter

Description

pBitmap

Pointer to the bitmap handle.

pSelClr

Pointer to a SELCLR structure that contains the selected colors along with the CMYK values for each.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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 pixel’s 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 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.

Required DLLs and Libraries

LTIMG

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

Windows 95 / 98 / Me, Windows 2000 / XP.

See Also

Functions:

L_SharpenBitmap, L_PosterizeBitmap, L_MosaicBitmap, L_EmbossBitmap, L_MedianFilterBitmap, L_AddBitmapNoise, L_IntensityDetectBitmap, L_SpatialFilterBitmap, L_BinaryFilterBitmap, L_MaxFilterBitmap, L_MinFilterBitmap, L_OilifyBitmap, L_SolarizeBitmap, L_DlgColor, L_WindowLevel, L_ColorLevelBitmap, L_AutoColorLevelBitmap, L_AdjustBitmapTint, L_ColorHalfToneBitmap

Topics:

Raster Image Functions: Modifying Intensity Values

 

Correcting Colors

 

Color Halftone and Halftone Images

 

Raster Image Functions: Correcting Colors

Example

/* 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 */
L_LoadBitmap
 (TEXT("IMAGE1.CMP"), &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
L_SelectiveColorBitmap
 (&LeadBitmap, &selClr);