'Division by zero'是怎么回事?
相关代码
void __fastcall TForm1::UpdatePic()
{
byte red,blue,green;
byte tr;
byte BW;
int x,y;
int r;
TMyColor c,c1,c2;
Graphics::TBitmap *b=new Graphics::TBitmap();
b->PixelFormat=pf24bit;
b->Width=sb->Width;
b->Height=sb->Height;
b->Canvas->Draw(0,0,sb);
red=fmSetup->TrackBar1->Position;
green=fmSetup->TrackBar2->Position;
blue=fmSetup->TrackBar3->Position;
tr=fmSetup->TrackBar4->Position;
BW=fmSetup->TrackBar5->Position;
for(x=0;x<sf->Width;x++)
for(y=0;y<sf->Height;y++)
{
r=BW;
if(x<r) r=x;
if(y<r) r=y;
if((sf->Width-x)<r) r=sf->Width-x;
if((sf->Height-y)<r) r=sf->Height-y;
c=GetSourcePixel(x+Posx,y+Posy,sb);
c1=GetSourcePixel(x,y,sf);
c1.Blue=(c.Blue*tr+c1.Blue*(100-tr)*blue/255)/100;
c1.Green=(c.Green*tr+c1.Green*(100-tr)*green/255)/100;
c1.Red=(c.Red*tr+c1.Red*(100-tr)*red/255)/100;
c2.Blue= (c.Blue*(BW-r)+r*c1.Blue)/BW ;
c2.Green= (c.Green*(BW-r)+r*c1.Green)/BW ;
c2.Red= (c.Red*(BW-r)+r*c1.Red)/BW ;
if((y+Posy)>=0 && (y+Posy)<b->Height && (x+Posx)>=0 && (x+Posx)<b->Width)
((TMyColor *)(b->ScanLine[y+Posy]))[x+Posx]=c2;
}
Image->Picture->Graphic=b;
b->Free();
运行的时候出现对话框:Debugger Exception Notification
project1.exe raised exception class EDivByZero with message 'Division by zero',Process stopped.Use step or Run to continue.
这是怎么回事呢?俺是新人,在网上下载的代码可以直接运行,可是自己又做了一遍就是这个结果,不知道怎么回事,请大虾们帮帮忙,谢谢拉