#include "ltwrappr.h"

L_INT LBitmap::WindowLevelExt(nLowBit, nHighBit, pLUT, ulLUTLength, uFlags)

Sets up the paint or paint and image processing functions' window leveling options for a specific bitmap.


L_INT nLowBit

Value indicating the low bit used for leveling. 0 <= nLowBit <= nHighBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).

L_INT nHighBit

Value indicating the high bit used for leveling. 0 <= nLowBit <= nHighBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).


Optional lookup table that can be used to implement a user defined conversion. For every intensity value between 0 and 2 raised to the power of (nHighBit - nLowBit + 1) - 1 there should be a corresponding entry in the lookup table that contains an RGB quad. If pLUT is NULL, the conversion is a normal shift (right or left) and the painted bitmap is 8-bit grayscale. If pLUT is not NULL, the painted bitmap is a 24-bit bitmap.

L_UINT ulLUTLength

Value indicating the number of entries pointed to by pLUT.

L_UINT uFlags

Flag that indicates whether pLUT is used by the paint and image processing functions or only by the paint functions.  Possible values are:

Value Meaning
WINDOWLEVEL_PAINT [0x00] pLUT is used only by the paint functions.
WINDOWLEVEL_PAINT_AND_PROCESSING [0x01] pLUT is used for both paint and image processing routines.


Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.


Provides "on demand" window leveling for the paint functions and does not alter the image data. To convert the image data to a window leveled bitmap, use LBitmap::WindowLevelBitmapExt.

If WINDOWLEVEL_PAINT_PROCESSING is specified, then all image processing functions will take the pLUT into account.

For information on saving bitmaps that have been window leveled, refer to Saving Window-Leveled Bitmaps.

LEADTOOLS supports two types of LUTs for 10-16-bit grayscale images (8-bit LUT and 16-bit LUT).  Typical grayscale image display and processing is done using an 8-bit LUT.  But, you can also use a 16-bit LUT, which offers more precision.  Some special video cards and monitors also support display of grayscale images using a 16-bit LUT.

This function supports 12 and 16-bit grayscale images. Support for 12 and 16-bit grayscale images is available only in the Document/Medical toolkits.

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


Win32, x64.

See Also





L_INT LBitmap__WindowLevelExtExample() 
   L_INT nRet; 
   LBitmap LeadBitmap; 
   nRet =LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("image1.cmp")), 0,ORDER_BGR); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet =LeadBitmap.WindowLevelExt(1, 5, NULL, 0, 0); 
   if(nRet !=SUCCESS) 
      return nRet; 
   return SUCCESS; 

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

LEADTOOLS Raster Imaging C++ Class Library Help