#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_SelectBitmapData (pDstBitmap, pSrcBitmap, crColor, uSrcLowBit, uSrcHighBit, uThreshold, bCombine, uFlags)


pointer to the destination bitmap handle


pointer to the source bitmap handle


color value that will be used for coloration

L_UINT uSrcLowBit;

position of the starting bit of the mask

L_UINT uSrcHighBit;

position of the ending bit of the mask

L_UINT uThreshold;

threshold value

L_BOOL bCombine;


L_UINT32 uFlags;


Selects a specified number of bits of an 8, 12 or 16-bit grayscale bitmap and puts them into a mask, then colors the bitmap depending on the mask. This can show bitmap variances depending on user-defined conditions.

It also can process the whole image or a region of the image. If a bitmap has a region, the effect is applied only to the region.

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.




Pointer to the destination bitmap that will contain the result of the function. This bitmap will be updated as a 24-bit RGB. The bitmap is assumed to be uninitialized, so you should free the bitmap before passing it to the function.


Pointer to the bitmap handle referencing the 8, 12 or 16-bit grayscale bitmap. pSrcBitmap will not be affected.


Color that will be used for showing the variances in the bitmap.


Position of the start bit that will construct the mask. The position is a zero based number.


Position of the end bit that will construct the mask. This is inclusive (it is part of the mask). The value should not be less than uSrcLowBit. You can also pass 1, which is interpreted as "highest bit" (pSrcBitmap->BitsPerPixel 1).


Value that indicates the threshold for showing the bitmap variances. If the mask value is greater or equal to the threshold value then the pixel will be colored using crColor. See bCombine for more details.


A flag which tells how to color the output pixels:


- Pixels with values greater than or equal to the threshold value are:


set to crColor (if bCombine is set to FALSE) or


AND-ed with crColor (if bCombine is TRUE). In this case, the source pixel is first converted to grayscale 24-bit and then AND-ed with crColor.


- Pixels with values less than the threshold value are:


set to black (if bCombine is set to FALSE) or


The RGB pixel value will be the same as the high byte source pixel value (if bCombine is TRUE). That is R = G = B = High byte values of the source pixel.


Reserved for future use. Must be 0.



The function was successful.

< 1

An error occurred. Refer to Return Codes.

Required DLLs and Libraries


For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.


Win32, x64, Linux.

See Also


L_WindowLevel, L_WindowLevelBitmap, L_GrayScaleToDuotone, L_GrayScaleToMultitone, L_ShiftBitmapData, L_ColorizeGrayBitmap, L_SelectiveColorBitmap, L_AdjustBitmapTint, L_ColorHalfToneBitmap


Raster Image Functions: Modifying Intensity Values


Grayscale Images


Using Color Values in LEADTOOLS


Color Halftone and Halftone Images


Raster Image Functions: Correcting Colors


This example loads a bitmap and applies Selecting.

L_INT SelectBitmapDataExample(L_VOID) 
   L_INT nRet; 
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */ 
   BITMAPHANDLE DstBitmap;     /* Bitmap handle to hold the result. */ 
   /* Load the bitmap, keeping the bits per pixel of the file */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("Slice.tif")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, NULL, NULL);  
   if(nRet !=SUCCESS) 
      return nRet; 
   // Call the function 
   nRet =L_SelectBitmapData (&DstBitmap,  
                              RGB(233, 10, 77),  
                              2 /* uSrcLowBit */, 
                              6 /* uSrcHighBit */, 
                              25 /* uThreshold */, 
                              TRUE, 0);   
   if(nRet !=SUCCESS) 
      return nRet; 
   // Now we have the resulted image in DstBitmap 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &DstBitmap, FILE_BMP, 24, 0, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   //free bitmap  
   return SUCCESS; 

Help Version 20.0.2019.3.12
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help