L_LTIMGCOR_API L_INT L_WindowLevelBitmapExt (pBitmap, nLowBit, nHighBit, pLUT, uLUTLength, nOrderDst, uFlags)
Converts a 12 or 16-bit grayscale image to an 16-bit grayscale or a 48-bit RGB bitmap.
Pointer to the bitmap handle referencing the bitmap to be leveled.
Value indicating the low bit used for leveling. 0 <= nLowBit <= nHighBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).
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 (
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 output bitmap is 8-bit grayscale. If pLUT is not NULL, the output bitmap is a 24-bit bitmap.
Value indicating the number of entries pointed to by pLUT.
Value indicating the color order if the output bitmap will be 24-bit. If
pLUT is NULL, this parameter is ignored. Possible values are:
|ORDER_RGB|| The input colors are in red-green-blue order.|
|ORDER_BGR|| The input colors are in blue-green-red order.|
Reserved for future use. Must be 0.
|SUCCESS||The function was successful.|
|< 1||An error occurred. Refer to Return Codes.|
This function will convert the bitmap to a window-leveled bitmap. To implement window-leveling without affecting the image, use L_WindowLevelExt.
The bitmap data is changed by this function.
This function supports 12 and 16-bit grayscale. Support for 12 and 16-bit grayscale images is available in the Document and Medical Imaging toolkits.
This function is similar to L_WindowLevelBitmap, except that it uses 16-bit per component LUT instead of 8-bit per component LUT.
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 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, Linux.
This example window levels the bitmap with a custom palette. The image data is changed in this example.
L_INT WindowLevelBitmapExtExample(pBITMAPHANDLE pBitmap)
/* Load an pass a 16-bit grayscale image */
L_RGBQUAD16 * ptmp;
L_RGBQUAD16 * pLUT;
/* Change the bitmap to 16-bit grayscale */
nRet = L_GrayScaleBitmap(pBitmap, 16);
nRet = L_GetMinMaxBits(pBitmap, &nLowBit, &nHighBit, 0);
nRet = L_GetMinMaxVal(pBitmap, &nLow, &nHigh, 0);
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 */
ptmp->rgbRed = 0xFFFF;
ptmp->rgbGreen = 0;
ptmp->rgbBlue = 0;
ptmp->rgbReserved = 0;
/* fill the rest with gray values */
ptmp->rgbRed = (( L_UINT16) ((L_UINT32) (x - nLow) * 0xFFFF / (nHigh - nLow)));
ptmp->rgbGreen = ptmp->rgbRed;
ptmp->rgbBlue = ptmp->rgbGreen;
ptmp->rgbReserved = 0;
nRet = L_WindowLevelBitmapExt ( pBitmap, nLowBit, nHighBit, pLUT, nSize, ORDER_BGR, 0);
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries