LDialogColor::DoModalWindowLevel

Summary

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

Syntax

#include "ltwrappr.h"

virtual L_INT LDialogColor::DoModalWindowLevel (hWndOwner)

Parameters

HWND hWndOwner

Handle of the window which owns the dialog.

Returns

Value Meaning
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

See Also

Functions

Topics

Example

L_INT LDialogColor_DoModalWindowLevelExample(LBitmap * pBitmap, HWND hWnd) 
{ 
   L_INT nRet; 
   L_INT nSize = 0 ; 
 
   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; 
 
   nSize = ( L_UINT32 ) ( 1L<< ( nHighBit - nLowBit + 1 ) ) ; 
   WINDOWLEVELDLGPARAMS  DlgParams;  
   memset ( &DlgParams, 0, sizeof ( WINDOWLEVELDLGPARAMS ) ) ; 
 
   DlgParams.uStructSize      = sizeof ( WINDOWLEVELDLGPARAMS ) ; 
   DlgParams.pLUT              = ( RGBQUAD * ) malloc ( ( nSize * sizeof ( RGBQUAD ) ) ) ; 
   DlgParams.uLUTLength        = ( L_UINT32 ) nSize ; 
   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; 
} 
Help Version 22.0.2023.2.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Common Dialog C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.