以下程序错在哪了?
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "math.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm1 *Form1;
int xs,ys,xt,yt;
int xx,yy;
//TColor bco, fco;
void bh(int x1,int y1,int x2,int y2,TColor co,HDC dc)
{
int x,y,e,m,dx,dy,k;
float l;
dx=x2-x1;
dy=y2-y1;
x=x1;
y=y1;
if(dx==0)
for(k=0;k SetPixel(dc,x,y++,co);
else if(dy==0)
for(k=0;k SetPixel(dc,x++,y,co);
else
{m=dy/dx;
l=sqrt(dx*dx+dy*dy);
if(abs(m)<=1) e=2*abs(dy)-abs(dx);
else e=2*abs(dx)-abs(dy);
for(k=1;k{
SetPixel(dc,x,y,co);
if(e>0)
{
if(abs(m)<=1)
{
if(dy>0) y++;
else y--;
e-=2*abs(dx);
}
else
{
if(dx>0) x++;
else x--;
e-=2*abs(dy);
}
}
if(abs(m)<=1)
{
if(dx>0) x++;
else x--;
e+=2*abs(dy);
}
else
{
if(dy>0) y++;
else y--;
e+=2*abs(dx);
}
}
}
}
void Scanline_seed_fill(HDC dc,int x1,int y1,COLORREF co1,COLORREF co2)
{
int i,k,x,y,mx,my;
int a[20000],b[20000];
COLORREF rgbco;
a[0]=x1;
b[0]=y1;
k=0;
x=x1;
y=y1;
SetPixel(dc,x,y,co1);
while(k>=0)
{
x=a[k];
y=b[k];
k--;
rgbco=GetPixel(dc,x,y);
if(rgbco!=co1;;rgbco!=co2)
{
SetPixel(dc,x,y,co1);
Sleep(20);
}
mx=x;
my=y;
for(i=1;i<5;i++)
{
x=mx; y=my;
if(i==1) x++;
else if(i==2) y++;
else if(i==3) x--;
else y--;
rgbco=GetPixel(dc,x,y);
if(rgbco!=co1;;rgbco!=co2)
{
k++;
a[k]=x;
b[k]=y;
}
}
}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
xs=X;
ys=Y;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
xt=X;
yt=Y;
HDC dc=GetDC(Form1->Handle);
TColor co=clRed;
bh(xs,ys,xt,yt,co,dc);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HDC dc=GetDC(Form1->Handle);
TColor co1=clRed;
TColor co2=clBlue;
Scanline_seed_fill(dc,xx,yy,co1,co2);
}
//---------------------------------------------------------------------------