LBitmap::SelectData

#include "ltwrappr.h"

virtual L_INT LBitmap::SelectData (pDstBitmap, crColor, uSrcLowBit, uSrcHighBit, uThreshold, bCombine, uFlags = 0)

virtual L_INT LBitmap::SelectData (plDstBitmap, crColor, uSrcLowBit, uSrcHighBit, uThreshold, bCombine, uFlags = 0)

pBITMAPHANDLE pDstBitmap;

pointer to the source bitmap handle

COLORREF crColor;

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;

flag

LBitmapBase *plDstBitmap;

pointer to the source bitmap object

L_UINT32 uFlags;

flags

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.

Parameter

Description

pDstBitmap

Pointer to the source 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.

crColor

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

uSrcLowBit

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

uSrcHighBit

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" (pDstBitmap->BitsPerPixel 1).

uThreshold

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.

bCombine

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.

plDstBitmap

Pointer to the source bitmap object that will contain the result of the function. This bitmap object 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.

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 is used as a visualization aid. You can select certain bits of the supported type bitmap and show the variances of that bitmap under conditions that you define.

The pDstBitmap should not be allocated when calling this function. That is, you should free the allocated bitmap before calling this function. When the function returns successfully the pDstBitmap will be a 24-bit RGB bitmap.

For 8, 12 and 16-bit grayscale bitmap, the uSrcLowBit can range from 0 to 7, 11, and 15 respectively. However if this value exceeded the range then the function will not return an error, and the pDstBitmap will be a pure black bitmap.

For 8, 12 and 16-bit grayscale bitmap, the uSrcHighBit can range from uSrcLowBit to 7, 11, and 15 respectively. No error will be returned if uSrcHighBit is greater than 7, 11 or 15. The function will return an invalid parameter error if uSrcHighBit < uSrcLowBit.

The function will first construct a mask from bits uSrcLowBit through uSrcHighBit. For each pixel, the pixel value will be combined with the mask using a bitwise and operation. The result will be shifted to the right by uSrcLowBit. This result will be compared with the threshold: if the value is greater than or equal to the threshold, the output pixels color is changed using crColor. If the result is less than the threshold, the output is set to 0.

The following example shows you how to treat a 16-bit grayscale bitmap:

In a16-bit grayscale bitmap, the bits are ordered as b15 b14 b13 ... b2 b1 b0.

For uSrcLowBit = 3, uSrcHighBit = 8, uThreshold = 16 and crColor = RGB(0, 255, 0):

In Source bitmap (pDstBitmap)

------------------- 

b15 b14 b13 b12 b11 b10 b9 |b8 b7 b6 b5 b4 b3| b2 b1 b0

-------------------  

0 1 1 0 1 1 1 0 1 0 0 1 1 1 0 1 

In our case, the mask is 010011 in base 2 (19 in decimal). Since 19 >= 16, the destination pixel will be colored using rcColor. The output pixel will be:

if bCombine = FALSE: crColor = RGB(0,255,0)

if bCombine = TRUE: we take the high byte of the source pixel, which is 01101110 in base 2 (0x6E), and then the value is AND-ed with each component of the crColor. So the output pixel will be RGB(0x00 & 0x6E, 0xFF & 0x6E, 0x00 & 0x6E) which is RGB(0x00, 0x6E, 0x00).

Let us consider another case: the source pixel is 0110111000011101 the mask value is 000011 in base 2(3 in decimal). Since 3 < 16, the destination pixel will be:

if bCombine = FALSE: RGB(0,0,0)

if bCombine = TRUE: The high byte of source pixel will bet set for the RGB, that is RGB(0x6E, 0x6E, 0x6E).

To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.

This function supports 8, 12 and 16-bit grayscale bitmaps only. Support for 12 and 16-bit grayscale images are available only in the Document/Medical toolkits. 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.

Required DLLs and Libraries

LTIMGCOR

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:

LBitmap::AdjustTint. LBitmap::ColorHalfTone, LBitmap::WindowLevel, LBitmap::WindowLevelExt, LBitmap::WindowLevelBitmapExt, LBitmap::WindowLevelBitmap, LBitmap::GrayScaleToDuotone, LBitmap::GrayScaleToMultitone, LBitmap::ShiftData, LBitmap::ColorizeGray, LBitmap::SelectiveColor

Topics:

Raster Image Functions: Modifying Intensity Values

 

Grayscale Images

 

Using Color Values in LEADTOOLS

 

Color Halftones and Halftone Images

 

Raster Image Functions: Working with Color Halftones, Halftones, and Grayscale Images

 

Raster Image Functions: Correcting Colors

Example

L_INT LBitmap__SelectDataExample(LBitmap *pLeadBitmap, LBitmap *pSrcBitmap)  
{ 
   L_INT nRet; 
 
   /* This example applies Selecting. */ 
   // Call the function 
   nRet =pLeadBitmap->SelectData ( 
                            pSrcBitmap,  
                            RGB(233, 10, 77),  
                            2 /* uSrcLowBit */, 
                            6 /* uSrcHighBit */, 
                            25 /* uThreshold */, 
                            TRUE); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   pLeadBitmap->Free (); 
 
   // Now we have the resulted image in pLeadBitmap 
 
   return SUCCESS; 
} 
Help Version 20.0.2020.4.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help