Apache:
【技术贴】大家帮偶看看,怎么优化能提高这段代码的运行速度 [C++Builder]
[阅读: 659] 2006-01-02 21:48:11
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
Image1->Width=Image2->Width;
Image1->Height=Image2->Height;
Image1->Canvas->Draw(0,0,Image2->Picture->Graphic);
for (int x=0;x<=Image2->Width;x++)
{
for (int y=Image2->Height/4*2;y<=Image2->Height/4*3;y++) //
{
for (int w=0;w<=127;w++)
{
int Or,Og,Ob;
int Nr,Ng,Nb;
int Bright;
double Duibi;
Bright=w;
Duibi=1;
Or=GetRValue(Image1->Canvas->Pixels [x+w][y]);
Og=GetGValue(Image1->Canvas->Pixels [x+w][y]);
Ob=GetBValue(Image1->Canvas->Pixels [x+w][y]);
Nr=(Or-127)*Duibi+127+Bright;
Ng=(Og-127)*Duibi+127+Bright;
Nb=(Ob-127)*Duibi+127+Bright;
if (Nr>255) Nr=255;
if (Nr<0) Nr=0;
if (Ng>255) Ng=255;
if (Ng<0) Ng=0;
if (Nb>255) Nb=255;
if (Nb<0) Nb=0;
Image2->Canvas->Pixels [x+w][y]=RGB(Nr,Ng,Nb);
}
}
Image2->Refresh();
}
}