Brings up the Window Level dialog box, and gets the options for L_WindowLevel. This function is available in the Medical toolkits.
#include "l_bitmap.h"
L_LTDLG_API L_INT L_DlgWindowLevel(hWndOwner, pDlgParams)
Handle of the window which owns the dialog.
Pointer to a WINDOWLEVELDLGPARAMS structure to be updated with the user selected values. Set members of this structure to set the dialog initial values.
Value | Meaning |
---|---|
SUCCESS_DLG_OK | The dialog exits successfully after pressing the "OK" button. |
SUCCESS_DLG_CANCEL | The dialog exits successfully after pressing the "Cancel" button. |
< 1 | An error occurred. Refer to Return Codes. |
✎ NOTE
This dialog only works for 12 or 16 bit grayscale images. Trying to use this dialog with other images will result in an error.
You must allocate the memory for the LUT before calling this function. You can calculate the required size with (sizeof(RGBQUAD) * (1<<(pBitmap->HighBit - pBitmap->LowBit + 1))), as seen in the example below.
For example, suppose you are working with a 12 bit grayscale image. There are 4096 intensity levels in a 12 bit image (2 raised to the 12th power). Normally, the interval between 0 and 4095 would be mapped to colors between (0, 0, 0) and (255, 255, 255). With this function, any value that falls between the low level and the high level will be mapped to colors between the start color and the end color. If you do not want a gradient, set the start and end colors equal.
L_INT DlgWindowLevelExample(HWND hWnd,
pBITMAPHANDLE pBitmap)
{
L_INT nRet;
L_INT nSize = 0 ;
L_INT nHighBit,nLowBit;
WINDOWLEVELDLGPARAMS DlgParams;
nLowBit = pBitmap->LowBit;
nHighBit = 1<<(pBitmap->HighBit - pBitmap->LowBit + 1);
memset(&DlgParams, 0, sizeof (WINDOWLEVELDLGPARAMS));
nSize = ( L_UINT32 ) ( 1L<< ( nHighBit - nLowBit + 1 ) ) ;
DlgParams.uStructSize = sizeof (WINDOWLEVELDLGPARAMS);
DlgParams.pBitmap = pBitmap;
DlgParams.pLUT = ( RGBQUAD * ) malloc ( ( nSize * sizeof ( RGBQUAD ) ) ) ;
DlgParams.uLUTLength = ( L_UINT32 ) nSize ;
DlgParams.uLowBit = pBitmap->LowBit;
DlgParams.uHighBit = pBitmap->HighBit;
DlgParams.nLow = pBitmap->LowBit;
DlgParams.nHigh = 1<<(pBitmap->HighBit - pBitmap->LowBit + 1);
DlgParams.crStart = RGB(255,0,0);
DlgParams.crEnd = RGB(0,0,255);
DlgParams.nFactor = 10;
DlgParams.uWindowLevelFlags = FILLLUT_INSIDE|FILLLUT_LOGARITHMIC;
DlgParams.uDlgFlags = DLG_WINDOWLEVEL_SHOW_PREVIEW |
DLG_WINDOWLEVEL_AUTOPROCESS |
DLG_WINDOWLEVEL_SHOW_TOOL_ZOOMLEVEL |
DLG_WINDOWLEVEL_SHOW_RANGE ;
nRet = L_DlgInit ( DLG_INIT_COLOR ) ;
if(nRet != SUCCESS && nRet != ERROR_DLG_ALREADYINITIATED)
return nRet;
nRet = L_DlgWindowLevel ( hWnd, &DlgParams ) ;
if(nRet < 1)
return nRet;
L_DlgFree();
free(DlgParams.pLUT);
return SUCCESS;
}