#include "l_bitmap.h"
L_LTIMGCLR_API L_INT L_BalanceColors(pBitmap, pRedFact, pGreenFact, pBlueFact, uFlags)
Redistributes the RGB values of the specified bitmap, using the values stored in the specified structures.
Pointer to the bitmap handle that references the bitmap in which to balance the colors.
Pointer to a BALANCING structure that contains the values to use for redistributing the bitmap's red values.
Pointer to a BALANCING structure that contains the values to use for redistributing the bitmap's green values.
Pointer to a BALANCING structure that contains the values to use for redistributing the bitmap's blue values.
Reserved for future use. Must be 0.
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 each pixel in the bitmap, the red value is modified using the values pointed to by pRedFact
. This generates an intermediate red value, an intermediate green value and an intermediate blue value.
For each pixel in the bitmap the green value is modified using the values pointed to by pGreenFact
. This generates an intermediate red value, an intermediate green value and an intermediate blue value.
For each pixel in the bitmap the blue value is modified using the values pointed to by pBlueFact
. This generates an intermediate red value, an intermediate green value and an intermediate blue value.
The intermediate red values are added to generate the new red value for the pixel. The intermediate green values are added to generate the new green value for the pixel and the intermediate blue values are added to generate the new blue value for the pixel. This triplet forms the new RGB value for the pixel.
The Balancing structure has three components of type double: toRed, toGreen and toBlue. The possible values of each member must be within the range: 0.0 1.0.
This function supports 48 and 64-bit colored images.
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 assumes there is a bitmap loaded into Bitmap, which is of type BITMAPHANDLE.
L_INT BalanceColorsExample(L_VOID)
{
L_INT nRet;
BITMAPHANDLE Bitmap;
BALANCING RedFact, GreenFact, BlueFact;
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image2.jpg")), &Bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if(nRet != SUCCESS)
return nRet;
RedFact.uStructSize = sizeof(BALANCING);
RedFact.toRed=0.25;
RedFact.toGreen=0.50;
RedFact.toBlue=0.25;
GreenFact.uStructSize = sizeof(BALANCING);
GreenFact.toRed=0.30;
GreenFact.toGreen=0.40;
GreenFact.toBlue=0.30;
BlueFact.uStructSize = sizeof(BALANCING);
BlueFact.toRed=0.10;
BlueFact.toGreen=0.60;
BlueFact.toBlue=0.30;
nRet = L_BalanceColors(&Bitmap,&RedFact,&GreenFact,&BlueFact, 0);
if(nRet !=SUCCESS)
return nRet;
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &Bitmap, FILE_BMP, 24, 0, NULL);
if(nRet !=SUCCESS)
return nRet;
//free bitmap
if(Bitmap.Flags.Allocated)
L_FreeBitmap(&Bitmap);
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