BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cannot grasp example code shown..

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
David
Guest





PostPosted: Sat Feb 14, 2004 3:27 pm    Post subject: Cannot grasp example code shown.. Reply with quote



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..
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.