David Guest
|
Posted: Sat Feb 14, 2004 3:27 pm Post subject: Cannot grasp example code shown.. |
|
|
TRect Source1 = Rect(0, 0, Bitmapa->Width, Bitmapa->Height);
TRect Destination1 = Rect(0, 0, bitmap->Width, bitmap->Height);
bitmap->Canvas->CopyRect(Destination1, Bitmapa->Canvas, Source1);
I am trying to grasp the code example shown below. My application is
using 16bit image and the code below is written for 32 bit image. I
cannot grasp where the difference come into play. It works great with
a 32 bit image but I either need to adjust the snippet shown below or
raise my image to 32 bits.
Ann anyone give me some insight.
//Adjust Brightness and Contrast from value//
//Contrast, start at mid point (Gray)
const int GRAY = 0x7f;
int nStepB = (int)floor(Value * 0.01 * GRAY);
double dStepC = Contr * 0.01;
if (Contr > 99) dStepC = dStepC * dStepC * dStepC;
bitmap->Canvas->Pixels [0][0] = bitmap->Canvas->Pixels [0][0];
//Now do the actual brightness and contrast adjustment
for (int Row = 0; Row < bitmap->Height; Row++) {
RGBQUAD * Pixel = (RGBQUAD *) bitmap->ScanLine[Row];
for (int Col = 0; Col < bitmap->Width; Col++,Pixel++) {
if (Value > 0) {
int TmpPix;
TmpPix = Pixel->rgbRed + nStepB;
//Brightness
TmpPix = (int)floor((TmpPix - GRAY) * dStepC) + GRAY;
//Contrast
Pixel->rgbRed = (TmpPix < 0) ? 0 : (TmpPix > 255) ? 255 :
TmpPix;//0 min, 255 max
TmpPix = Pixel->rgbGreen + nStepB;
//Brightness
TmpPix = (int)floor((TmpPix - GRAY) * dStepC) + GRAY;
//Contrast
Pixel->rgbGreen = (TmpPix < 0) ? 0 : (TmpPix > 255) ? 255 :
TmpPix;//0 min, 255 max
TmpPix = Pixel->rgbBlue + nStepB;
//Brightness
TmpPix = (int)floor((TmpPix - GRAY) * dStepC) + GRAY;
//Contrast
Pixel->rgbBlue = (TmpPix < 0) ? 0 : (TmpPix > 255) ? 255 :
TmpPix;//min 0, 255 max
} } }
plz, thank you..
|
|