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_WindowLevelExt

Show in webframe

#include "l_bitmap.h"

L_LTDIS_API L_INT L_WindowLevelExt (pBitmap, nLowBit, nHighBit, pLUT, ulLUTLength, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_INT nLowBit;

/* low bit to use */

L_INT nHighBit;

/* high bit to use */

L_RGBQUAD16* pLUT;

/* 16-bit lookup table */

L_UINT ulLUTLength;

/* number of entries */

L_UINT uFlags;

/* flags */

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

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap to be leveled.

nLowBit

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

nHighBit

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

pLUT

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 a L_RGBQUAD16 entry. 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 16-bit grayscale or 48-bit bitmap (depending on whether the LUT contains only grayscale entries or whether it has color entries as well).

ulLUTLength

Value indicating the number of entries pointed to by pLUT. If pLUT is NULL, then set this to 0 too.

uFlags

Value indicating 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.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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 L_WindowLevelBitmapExt.

This function is similar to L_WindowLevel, except that it uses 16-bit per component LUT instead of 8-bit per component LUT. The 16-bit LUT offers more precision than the 8-bit LUT, so it is better to use L_WindowLevelExt instead of L_WindowLevel.

The 16-bit and 8-bit LUTs are synchronized, which means the LUT applied by L_WindowLevelExt will change the LUT applied with L_WindowLevel and vice versa.

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.

If WINDOW_LEVEL_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.

Required DLLs and Libraries

LTDIS

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_WindowLevel, L_WindowLevelBitmap, L_PaintDC, L_PaintDCCallback, L_ShiftBitmapData, L_WindowLevelBitmapExt, L_WindowLevelFillLUT, L_WindowLevelFillLUTExt

Topics:

Raster Image Functions: Palettes

 

Raster Image Functions: Displaying and Printing

 

Color Halftone and Halftone Images

 

Grayscale Images

 

Saving Window-Leveled Bitmaps

 

Raster Image Functions: Processing an Image

Example

This example sets the window-levell values for painting and processing the bitmap with a custom palette.

L_INT WindowLevelExtExample(pBITMAPHANDLE pBitmap)
{
   L_INT nRet;
   L_UINT32 x;
   L_RGBQUAD16* ptmp;
   L_RGBQUAD16* pLUT;
   L_INT    nLowBit;
   L_INT    nHighBit;
   L_INT    nLow;
   L_INT    nHigh;
   L_UINT32 nSize;
   /* Change the bitmap to 16-bit grayscale */
   nRet = L_GrayScaleBitmap(pBitmap, 16 );
   if(nRet != SUCCESS)
      return nRet;
   nRet = L_GetMinMaxBits(pBitmap, &nLowBit, &nHighBit, 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = L_GetMinMaxVal(pBitmap, &nLow, &nHigh, 0);
   if(nRet != SUCCESS)
      return nRet;
   nSize = (L_UINT32)(1L<<(pBitmap->HighBit - pBitmap->LowBit + 1));
   pLUT = (L_RGBQUAD16 *)GlobalAllocPtr(GHND, nSize * sizeof(L_RGBQUAD16));
   ptmp = pLUT;
   /* fill the first half of the LUT with RED */
   for(x=0;x<nSize/2;x++)
   {
      ptmp->rgbRed       = 0xFFFF;
      ptmp->rgbGreen     = 0;
      ptmp->rgbBlue      = 0;
      ptmp->rgbReserved  = 0;
      ptmp++;
   }
   /* fill the rest with gray values */
   for(x=nSize/2;x<nSize;x++)
   {
      ptmp->rgbRed       = ((L_UINT16) ((L_UINT32) (x - nLow) * 0xFFFF / (nHigh - nLow)));
      ptmp->rgbGreen     = ptmp->rgbRed;
      ptmp->rgbBlue      = ptmp->rgbGreen;
      ptmp->rgbReserved  = 0;
      ptmp++;
   }
   nRet = L_WindowLevelExt( pBitmap, nLowBit, nHighBit,
      pLUT, nSize, WINDOWLEVEL_PAINT_AND_PROCESSING );
   if(nRet != SUCCESS)
      return nRet;
   GlobalFreePtr(pLUT);
   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.