颜色填充
提示:这里可以添加技术概要
核心源码
var
Form1: TForm1;
FRendering: boolean;
org, next1: TPoint;
mycolor: byte;
implementation
{$R *.DFM}
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
pa: pbytearray;
oc: byte;
// n: TPixelFormat;
mybmp: tbitmap;
begin
if CheckBox1.Checked then
begin
mybmp := tbitmap.Create;
mybmp.Width := image1.Picture.Bitmap.Width;
mybmp.Height := image1.Picture.Bitmap.Height;
mybmp.Assign(image1.Picture.Bitmap);
mybmp.PixelFormat := pf8bit;
pa := mybmp.ScanLine[y];
oc := pa[x];
FillColors(mybmp, image1.picture.bitmap.Width,
image1.picture.bitmap.Height,
X, Y, oc, mycolor);
image1.Picture.Bitmap.Assign(mybmp);
mybmp.free;
frendering := false;
end
else
begin
FRendering := true;
org := Point(X, Y);
next1 := Point(X, Y);
end;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
points: array[1…4] of TPOINT;
// p: pchar;
begin
if FRendering then
begin
next1 := Point(X, Y);
points[1] := org;
points[2] := next1;
points[3] := Point(nex