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_ColorReplaceBitmap

Show in webframe

#include "l_bitmap.h"

L_LTIMGCLR_API L_INT L_ColorReplaceBitmap(pBitmap, pColorReplace, uColorCount, nHue, nSaturation, nBrightness, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

pCOLORREPLACE pColorReplace;

/* array of COLORREPLACE structures */

L_UINT uColorCount;

/* number of colors */

L_INT nHue;

/* angular amount to change the hue, in degrees */

L_INT nSaturation;

/* amount to change saturation */

L_INT nBrightness;

/* amount to change the brightness */

L_UINT32 uFlags;

/* flags */

Replaces specified colors by adjusting values of hue, saturation and brightness.

Parameter

Description

pBitmap

Pointer to the bitmap handle that references the bitmap on which to apply the effect.

pColorReplace

An array of COLORREPLACE structures, one for each color to be replaced.

uColorCount

The number of colors to be replaced.

nHue

Angular amount to change the hue, in hundredths of degrees. Valid values range from 18000 to 18000. This value is divided internally by 100.

nSaturation

Amount to change saturation, in tenths of percent. Valid values range from 1000 to 1000. This value is divided internally by 10. Negative values decrease the saturation of colors. Positive values increase the saturation. The saturation level is increased or decreased by a percentage of its present saturation level. For example, an increase of 20% of the current saturation level "L" will raise the new saturation level "L1" to a value L = 0.20 * L. Likewise, increasing the saturation level 100% doubles the saturation level (L1 = L + 1.0 * L). Decreasing the saturation level 100% will set the new saturation level to 0. The saturation is set to 1000 (maximum value) if the new value exceeds 1000).

nBrightness

Amount to change the brightness, in tenths of percent. Valid values range from 1000 to 1000. This value is divided internally by 10. Positive values increase (or lighten) the brightness of the bitmap image. Negative values decrease (or darken) the brightness of the bitmap image.

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 replaces specified colors by adjusting their value of hue, saturation and brightness. The value of the uFuzziness member of the COLORREPLACE structure determines the range around each color where the pixels will be changed according to nHue, nSaturation and nBrightness.

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.

The pColorReplace->uStructSize must be set to sizeof(COLORREPLACE) before calling this function. For an array of structures, only the first structure in the array needs to have uStructSize member set.

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_ChangeBitmapIntensity, L_GammaCorrectBitmap, L_ChangeBitmapContrast, L_HistoContrastBitmap, L_StretchBitmapIntensity, L_RemapBitmapIntensity, L_InvertBitmap, L_ChangeBitmapSaturation, L_HistoEqualizeBitmap, L_FillBitmap, L_GetPixelColor, L_PutPixelColor, L_GetBitmapHistogram, L_WindowLevel, L_ChangeBitmapHue, L_AverageFilterBitmap, L_MedianFilterBitmap, L_AddBitmapNoise, L_IntensityDetectBitmap, L_SpatialFilterBitmap, L_BinaryFilterBitmap, L_MaxFilterBitmap, L_MinFilterBitmap, L_AddShadowBitmap, L_ChangeHueSatIntBitmap, L_ColorThresholdBitmap, L_DFTBitmap, L_AllocFTArray, L_DirectionEdgeStatisticalBitmap, L_FFTBitmap, L_FreeFTArray, L_FrqFilterBitmap, L_FrqFilterMaskBitmap, L_FTDisplayBitmap, L_GetBitmapStatisticsInfo, L_GetFeretsDiameter, L_GetObjectInfo, L_GetRgnContourPoints, L_GetRgnPerimeterLength, L_MathFunctionBitmap, L_RevEffectBitmap, L_SegmentBitmap, L_SubtractBackgroundBitmap, L_UserFilterBitmap, L_AdjustBitmapTint, L_ColorHalfToneBitmap

Topics:

Raster Image Functions: Modifying Intensity Values

 

Correcting Colors

 

Raster Image Functions: Correcting Colors

Example

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


#if defined (LEADTOOLS_V16_OR_LATER)
 L_INT ColorReplaceBitmapExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle for the image */
   COLORREPLACE ColorReplace; /*replaced color structure information*/
   /* Load a bitmap at its own bits per pixel  */
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT ("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   /* Change the red color by rotating its hue 90 degree*/
   ColorReplace.uStructSize = sizeof(COLORREPLACE);
   ColorReplace.crColor       = RGB(200, 0, 35);
   ColorReplace. uFuzziness = 100; 
   nRet = L_ColorReplaceBitmap(&LeadBitmap, &ColorReplace, 1, 9000, 0, 0, 0);
   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;
}
#else
 L_INT ColorReplaceBitmapExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle for the image */
   COLORREPLACE ColorReplace; /*replaced color structure information*/
   /* Load a bitmap at its own bits per pixel  */
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT ("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   /* Change the red color by rotating its hue 90 degree*/
   ColorReplace.uStructSize = sizeof(COLORREPLACE);
   ColorReplace.crColor       = RGB(200, 0, 35);
   ColorReplace. uFuzziness = 100; 
   nRet = L_ColorReplaceBitmap(&LeadBitmap, &ColorReplace, 1, 9000, 0, 0);
   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;
}
#endif // LEADTOOLS_V16_OR_LATER
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.