LevelLUT example for C++ Builder
This is also the example for MinVal property and MaxVal property.
The following example sets LevelLowBit and LevelHighBit to use all bits, gets the minimum and maximum bits and intensity values for the image, and then sets the LUT so that pixels with values in the minimum range are mapped to the color RED, while pixels with values in the maximum range are mapped to BLUE.
long int min;
long int max;
long int i;
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 that min range maps to RED and max range maps to BLUE
for (i = min; i <= min+100; i++)
Lead1->LevelLUT[i] = RGB(255, 0, 0);
for (i = max-100; i <= max; i++)
Lead1->LevelLUT[i] = RGB(0, 0, 255);
Lead1->AutoRepaint = True;