L_ColorLevelBitmap

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_ColorLevelBitmap(pBitmap, pLvlClr, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

pLVLCLR pLvlClr;

/* pointer to a LVLCLR structure */

L_UINT uFlags;

/* a flag that indicates the channel being color leveled */

Applies color leveling to an image. It changes the image shadows, midtones and highlights. This function is available in the Raster Pro and above toolkits.

Parameter

Description

pBitmap

Pointer to the bitmap handle.

pLvlClr

Pointer to a LVLCLR structure that contains several LVLCLRINF structures, which in turn contain information on the shadows, midtones and highlights for the Red, Green, Blue and Master channels.

uFlags

Flag that indicates the channel being leveled. Possible values are:

 

Value

Meaning

 

LEVEL_RED

[0x0001] Red channel

 

LEVEL_GREEN

[0x0010] Green channel

 

LEVEL_BLUE

[0x0100] Blue channel

 

LEVEL_MASTER

[0x1000] All channels

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Before you call the L_ColorLevelBitmap function, you need to initialize the size and all remaining fields of the LVLCLRINF structures within the LVLCLR structure. These fields tell L_ColorLevelBitmap what constitutes shadows, midtones, and highlights and how to remap the shadows, midtones and highlights.

Control the amount of image balance and leveling by controlling the values of the uMinInput, uMaxInput, uMinOutput, uMaxOutput, and uGamma members of the LVLCLRINF structure contained in the pLvlClr parameter.

image\sqrblit.gif The uMinInput member of an LVLCLRINF structure defines what the function interprets as shadows for that color channel. Any value less than or equal to uMinInput is considered a shadow.

image\sqrblit.gif The uMaxInput member of an LVLCLRINF structure defines what the function interprets as highlights for that color channel. Any value greater than or equal to uMaxInput is considered a highlight.

image\sqrblit.gif The value of the uMaxInput member must be greater than the value of the uMinInput member by at least 2.

image\sqrblit.gif Midtones are those values between uMinInput and uMaxInput.

image\sqrblit.gif The uMinOutput member is the value to which the shadows will be mapped.

image\sqrblit.gif The uMaxOutput member is the value to which the highlights will be mapped.

image\sqrblit.gif The uGamma member is used to modify the midtone values

If only LEVEL_MASTER is set in uFlags then the rest of the channels will still be affected.

If the image is a grayscale image, then you must set LEVEL_MASTER in uFlags, otherwise the function will not have any effect.

If uMinOutput > uMaxOutput then the bitmap’s shadows and highlights will be inverted.

To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.

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.

If the image 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_AutoColorLevelBitmap, L_SelectiveColorBitmap, L_AdjustBitmapTint, L_ColorHalfToneBitmap

Topics:

Raster Image Functions: Modifying Intensity Values

 

Changing Brightness and Contrast

 

Raster Image Functions: Changing Brightness and Contrast

 

Correcting Colors

 

Color Halftone and Halftone Images

 

Raster Image Functions: Correcting Colors

Example

For complete sample code, refer to the CHILD.C module of the DEMO example.

/* This example loads a bitmap and applies image leveling to it. */
BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */
LVLCLR lvlClr; 

/* Load the bitmap, keeping the bits per pixel of the file */
L_LoadBitmap
 (TEXT("IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);

lvlClr.uStructSize = sizeof(LVLCLR);
/* Specify Image levels */
lvlClr.blue.uMinInput = 20;
lvlClr.blue.uMaxInput = 200;
lvlClr.blue.uMinOutput = 0;
lvlClr.blue.uMaxOutput = 255;
lvlClr.blue.uGamma = DEFAULT_GAMMA;

// Master will cause the image to be Inversed
lvlClr.master.uMinInput = 0;
lvlClr.master.uMaxInput = 255;
lvlClr.master.uMinOutput = 255;
lvlClr.master.uMaxOutput = 0;
lvlClr.master.uGamma = DEFAULT_GAMMA;

/* Level the Blue and Master channels */
L_ColorLevelBitmap
 (&LeadBitmap, &lvlClr, LEVEL_BLUE | LEVEL_MASTER);