Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

L_BalanceColors

Show in webframe

#include "l_bitmap.h"

L_LTIMGCLR_API L_INT L_BalanceColors(pBitmap, pRedFact, pGreenFact, pBlueFact, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

BALANCING *pRedFact;

/* pointer to a structure */

BALANCING *pGreenFact;

/* pointer to a structure */

BALANCING *pBlueFact;

/* pointer to a structure */

L_UINT32 uFlags;

/* flags */

Redistributes the RGB values of the specified bitmap, using the values stored in the specified structures.

Parameter

Description

pBitmap

Pointer to the bitmap handle that references the bitmap in which to balance the colors.

pRedFact

Pointer to a BALANCING structure that contains the values to use for redistributing the bitmap's red values.

pGreenFact

Pointer to a BALANCING structure that contains the values to use for redistributing the bitmap's green values.

pBlueFact

Pointer to a BALANCING structure that contains the values to use for redistributing the bitmap's blue values.

uFlags

Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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

LTIMGCLR

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

Win32, x64, Linux.

See Also

Functions:

L_ConvertToColoredGray, L_GrayScaleBitmap, L_GrayScaleBitmapExt, L_IsGrayScaleBitmap, L_AdjustBitmapTint, L_ColorHalfToneBitmap

Topics:

Correcting Colors

 

Raster Image Functions: Modifying Intensity Values

 

Raster Image Functions: Correcting Colors

Example

This example assumes there is a bitmap loaded into Bitmap, which is of type BITMAPHANDLE.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName


#if defined (LEADTOOLS_V16_OR_LATER)
 L_INT BalanceColorsExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE Bitmap;
   BALANCING RedFact, GreenFact, BlueFact;

   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &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;
}
#else
 L_INT BalanceColorsExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE Bitmap;
   BALANCING RedFact, GreenFact, BlueFact;

   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &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);
   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;
}
#endif // LEADTOOLS_V16_OR_LATER
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.