#include "l_bitmap.h"
L_LTIMGCLR_API L_INT L_SampleTargetBitmap(pBitmap, crSample, crTarget, uFlags)
Corrects color values by shifting the sample colors to the target colors.
Pointer to the bitmap handle referencing the bitmap to be changed.
The COLORREF value that specifies the Sample color. The red value for red channel, green value for green channel, blue value for blue channel.
The COLORREF value that specifies the Target color. The red value for red channel, green value for green channel, blue value for blue channel.
Flags that indicates the channel for which to shift the color and how to remap the other values for that channel. You can use a bit wise OR (|) to specify one flag from each group.
Value | Meaning |
---|---|
SAMP_RED | [0x0001] Shift the color in the red channel. |
SAMP_GREEN | [0x0002] Shift the color in the green channel. |
SAMP_BLUE | [0x0003] Shift the color in the blue channel. |
SAMP_RGB | [0x0004] Shift the color in the red, green, and blue channels. |
Value | Meaning |
---|---|
SAMP_LOW | [0x0010] Remap the shadow values for the channel set in uFlags. |
SAMP_MID | [0x0020] Remap the midtone values for the channel set in uFlags. |
SAMP_HIGH | [0x0030] Remap the highlight values for the channel set in uFlags. |
Value | Meaning |
---|---|
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.
For example, suppose you are working with a color image. In crSample
you set the red value portion of the COLORREF structure to 125, the green portion to 165 and the blue portion to 100. In crTarget you set the red value portion to 170, the green to 120 and the blue to 200. If you set SAMP_BLUE in uFlags, then for every pixel in the bitmap that has a blue value of 100, that blue value will be changed to 200, thus shifting the colors in the bitmap. Depending on whether you set SAMP_LOW, SAMP_MID, or SAMP_HIGH, either the shadow values in the blue channel will be remapped, or the midtone values in the blue channel will be remapped, or the highlight values in the blue channel will be remapped.
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 in the Document and Medical Imaging toolkits.
For gray scale bitmaps the gray value of the crSample and crTarget
are used, and the different channel flags have the same effect since it works on the same channel (gray channel).
To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.
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.
The following example loads bitmap, and applies the sample target function:
L_INT SampleTargetBitmapExample(L_VOID)
{
L_INT nRet;
BITMAPHANDLE LeadBitmap;
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("sample5.cmp")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if(nRet !=SUCCESS)
return nRet;
/*Apply the filter*/
nRet = L_SampleTargetBitmap(&LeadBitmap, RGB(50, 100, 150), RGB(60, 90 , 150), SAMP_RED| SAMP_MID);
if(nRet !=SUCCESS)
return nRet;
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL);
if(nRet !=SUCCESS)
return nRet;
//free bitmap
if(LeadBitmap.Flags.Allocated)
L_FreeBitmap(&LeadBitmap);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document