LDialogColor::DoModalWindowLevel

#include "ltwrappr.h"

virtual L_INT LDialogColor::DoModalWindowLevel (hWndOwner)

HWND hWndOwner;

/* handle of the window which owns the dialog */

Brings up the Window Level dialog box, and gets the options for LBitmap::WindowLevel. This function is available in the Medical toolkits.

Parameter

Description

hWndOwner

Handle of the window which owns the dialog.

Returns

SUCCESS_DLG_OK

The "OK" button was pressed, and the dialog exited successfully.

SUCCESS_DLG_CANCEL

The "Cancel" button was pressed, and the dialog exited successfully.

< 1

An error occurred. Refer to Return Codes.

Comments

The Window Level dialog.

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<<(nHighBit - nLowBit + 1))), you can get the nHighBit and nLowBit values by using LBitmap::GetMinMaxBits function 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.

Required DLLs and Libraries

LTDLGCLR
LTDLGKRN
LTDLGUTL
LTDLGCTRL
LTDLGCOM
LTDIS
LTIMG

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

LDialogBase::Initialize, Class Members

Topics:

Using Imaging Common Dialog

 

HSB-Brightness Based Model

 

HSB-Hue Based Model

 

HSB-Wheel Based Model

 

RGB-3D Additive Model

 

Lab-Device Independent Model

 

CMY-3D Subtractive Model

 

CMYK -3D Subtractive Model

Example

L_INT LDialogColor_DoModalWindowLevelExample(LBitmap * pBitmap, HWND hWnd)
{
   L_INT nRet;
   LDialogColor DlgColor;
   nRet = DlgColor.Initialize(DLG_INIT_COLOR );
   if(nRet != SUCCESS)
      return nRet;
   DlgColor.SetBitmap(pBitmap);
   L_INT nHighBit,nLowBit;
   nHighBit = 0;
   nLowBit  = 0;
   nRet = pBitmap->GetMinMaxBits (&nLowBit,&nHighBit); 
   if(nRet != SUCCESS)
      return nRet;
   WINDOWLEVELDLGPARAMS  DlgParams; 
   memset ( &DlgParams, 0, sizeof ( WINDOWLEVELDLGPARAMS ) ) ;
   DlgParams.uStructSize      = sizeof ( WINDOWLEVELDLGPARAMS ) ;
   DlgParams.pLUT              = (L_RGBQUAD*) malloc ( sizeof ( RGBQUAD ) * (L_INT)((L_INT32)1<<(nHighBit - nLowBit + 1)));
   DlgParams.uLowBit           = nLowBit;
   DlgParams.uHighBit           = nHighBit;
   DlgParams.nLow              = nLowBit;
   DlgParams.nHigh             = 1<<(nHighBit - nLowBit + 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_RANGE ;
   DlgColor.EnableCallBack (FALSE);
   DlgColor.EnablePreview(TRUE);
   DlgColor.EnableAutoProcess(TRUE);
   DlgColor.EnableToolbar(TRUE);
   nRet = DlgColor.SetWindowLevelParams(&DlgParams) ;
   if(nRet != SUCCESS)
      return nRet;
   nRet = DlgColor.DoModalWindowLevel(hWnd);
   if(nRet < 1)
      return nRet;
   // Gets the updated values for the structure
   nRet = DlgColor.GetWindowLevelParams(&DlgParams, sizeof(DlgParams)) ;
   if(nRet != SUCCESS)
      return nRet;
   nRet = DlgColor.Free ();
   if(nRet != SUCCESS)
      return nRet;
   free(DlgParams.pLUT);
   return SUCCESS;
}