L_ChannelMix

#include "l_bitmap.h"

L_LTIMGCLR_API L_INT L_ChannelMix(pBitmap, pRedFactor, pGreenFactor, pBlueFactor, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

COLORDATA *pRedFactor;

/* pointer to a structure */

COLORDATA *pGreenFactor;

/* pointer to a structure */

COLORDATA *pBlueFactor;

/* 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 which will undergo color redistribution.

pRedFactor

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

pGreenFactor

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

pBlueFactor

Pointer to a COLORDATA 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.

This function is used to rebalance the colors in a bitmap. It can be used to make color adjustments and corrections.

This function supports 1-, 2-, 3-, 4-, 5-, 6-, 7-, 8-, 24-, 48- and 64-bit bitmaps and can support regions for 24-, 48- and 64-bit bitmaps. If the bitmap has a region, the effect will be applied on the region only.

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.

See Also

Functions:

L_ConvertToColoredGray, L_BalanceColors, L_GrayScaleBitmap, L_GrayScaleBitmapExt, L_IsGrayScaleBitmap, L_AutoColorLevelBitmap, L_ColorLevelBitmap, L_CorrelationBitmap, L_GrayScaleToDuotone, L_GrayScaleToMultitone, L_HolesRemovalBitmapRgn, L_SelectiveColorBitmap, L_SkeletonBitmap, L_AdjustBitmapTint, L_ColorHalfToneBitmap

Topics:

Correcting Colors

 

Raster Image Functions: Modifying Intensity Values

 

Color Halftone and Halftone Images

 

Raster Image Functions: Correcting Colors

Example

The following example loads a bitmap and then applies the L_ChannelMix function to it:

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


#if defined (LEADTOOLS_V16_OR_LATER)
 L_INT ChannelMixExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE Bitmap;
   COLORDATA 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(COLORDATA);
   RedFact.nRedFactor = 50;
   RedFact.nGreenFactor = 0;
   RedFact.nBlueFactor = 0;
   RedFact.nConstant = 0;

   GreenFact.uStructSize = sizeof(COLORDATA);
   GreenFact.nRedFactor = 100;
   GreenFact.nGreenFactor = 100;
   GreenFact.nBlueFactor = 0;
   GreenFact.nConstant = 0;

   BlueFact.uStructSize = sizeof(COLORDATA);
   BlueFact.nRedFactor = 0;
   BlueFact.nGreenFactor = 0;
   BlueFact.nBlueFactor = 100;
   BlueFact.nConstant = 0;

   nRet = L_ChannelMix(&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 ChannelMixExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE Bitmap;
   COLORDATA 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(COLORDATA);
   RedFact.nRedFactor = 50;
   RedFact.nGreenFactor = 0;
   RedFact.nBlueFactor = 0;
   RedFact.nConstant = 0;

   GreenFact.uStructSize = sizeof(COLORDATA);
   GreenFact.nRedFactor = 100;
   GreenFact.nGreenFactor = 100;
   GreenFact.nBlueFactor = 0;
   GreenFact.nConstant = 0;

   BlueFact.uStructSize = sizeof(COLORDATA);
   BlueFact.nRedFactor = 0;
   BlueFact.nGreenFactor = 0;
   BlueFact.nBlueFactor = 100;
   BlueFact.nConstant = 0;

   nRet = L_ChannelMix(&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