L_LightControlBitmap
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_LightControlBitmap(pBitmap, puLowerAvr, puAverage, puUpperAvr,uFlag)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
/* pointer to the new low average(s) array */ | |
/* pointer to the new average(s) array */ | |
/* pointer to the new high average(s) array */ | |
L_UINT uFlag; |
/* flag */ |
Lightens or darkens all or part of a bitmap by remapping the pixel values.
Parameter |
Description |
|
pBitmap |
Pointer to the bitmap handle referencing the bitmap to be changed. |
|
puLowerAvr |
Pointer to an array containing the new average pixel value for those pixels with values between 0 and the average pixel value for the entire bitmap. The size of the array equals one, if uFlag is YUV_SPACE or GRAY_SPACE, or three, if uFlag is RGB_SPACE. If uFlag is RGB_SPACE the first element corresponds to the new blue lower average value, the second element to the green, and the last element to the red. |
|
puAverage |
Pointer to an array containing the new average pixel value for the entire bitmap. The size of the array equals one, if uFlag is YUV_SPACE or GRAY_SPACE, or three, if uFlag is RGB_SPACE. If uFlag is RGB_SPACE the first element corresponds to the new blue average value, the second element to the green, and the last element to the red. |
|
puUpperAvr |
Pointer to an array containing the new average pixel value for those pixels with values between the average pixel value for the entire bitmap and the highest pixel value in the bitmap. The size of the array equals either one if uFlag is YUV_SPACE or GRAY_SPACE or three if uFlag is RGB_SPACE where the first element corresponds to the new blue upper side average value, the second element to the green, and the last element to the red. |
|
uFlag |
Flag that indicates which color space to remap. Possible values are: |
|
|
Value |
Meaning |
|
RGB_SPACE |
[0x0001] Use the histogram of RGB color space. (separated channels) |
|
YUV_SPACE |
[0x0002] Use the histogram of YUV color space.(Best results) |
|
GRAY_SPACE |
[0x0004] Use the histogram of a gray level representation of the image. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function remaps the pixel values of the bitmap across the full range of available pixel values, in order to achieve the values passed in puLowerAvr, puAverage and puUpperAvr.
For example, call this function for a grayscale bitmap, with puAverage containing 150, puLowerAvr containing 100 and puUpperAvr containing 190. The pixels of the bitmap will be remapped so that the new average pixel value for the entire bitmap will be 150, the new average value for those pixels with a value between 0 and the average value for the entire bitmap will be 100, and the new average value for those pixels with a value between the average value for the entire bitmap and the maximum pixel value in the bitmap will be 190.
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.
To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.
For an example, see the following figure:
The following figure shows the same bitmap, after the effect has been applied:
To obtain this effect, the following settings were used with the function:
uLowerAvr = 100
uAverage = 255
uUpperAvr = 255
uFlag = YUV_SPACE
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
Example
/* The following example loads a bitmap and applies light control function. */
BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */
L_UINT puLowerAvr[3];
L_UINT puAverage[3];
L_UINT puUpperAvr[3];
puLowerAvr[0] = 100; /*for blue, gray or yuv*/
puLowerAvr[1] = 120; /*for green*/
puLowerAvr[2] = 80; /*for red*/
puAverage[0] = 150; /*for blue, gray or yuy*/
puAverage[1] = 140; /*for green*/
puAverage[2] = 128; /*for red*/
puUpperAvr[0] = 190; /*for blue, gray or yuv*/
puUpperAvr[1] = 200; /*for green*/
puUpperAvr[2] = 220; /*for red*/
/* Load the bitmap, keeping the bits per pixel of the file */
L_LoadBitmap(TEXT("IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
/* change the lightness of the bitmap */
L_LightControlBitmap(&LeadBitmap, puLowerAvr, puAverage, puUpperAvr, YUV_SPACE);