WindowLevelBitmap example for C++ Builder
This example loads a 16-bit grayscale, fills the window level lookup table, and window levels the bitmap for display only
void __fastcall TForm1::WndLvlBmpClick(TObject *Sender)
{
int min, max, i;
// Load a 16-bit grayscale image
Lead1->Load("test.tif", 0, 0, 1);
Lead1->AutoRepaint = False;
// Use all bits
Lead1->LevelLowBit = 0;
Lead1->LevelHighBit = Lead1->BitmapBits - 1;
Lead1->GetMinMaxBits();
Lead1->GetMinMaxVal();
max = Lead1->MaxVal;
min = Lead1->MinVal;
// Set LUT so it ranges from pure blue to pure red
for(i=min; i<max; i++)
Lead1->LevelLUT[i] = (TColor)RGB(i % 256, 0, 256 - i % 256);
//Window level for display only -- leave the bitmap data unchanged
Lead1->WindowLevelBitmap = True;
Lead1->WindowLevel();
Lead1->ForceRepaint();
}