From bc0375d33183f0221fbd041378cc2bc1dcded92a Mon Sep 17 00:00:00 2001 From: yangjixian Date: Thu, 21 Apr 2011 02:04:35 +0000 Subject: [PATCH] FloodFill works. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1588 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/lazimageeditor/DLBitmap.pas | 7 + applications/lazimageeditor/bmprgbtypes.pas | 3 +- .../lazimageeditor/lazimageeditor.lpi | 162 +++++++++--------- applications/lazimageeditor/picturectrls.pas | 4 +- 4 files changed, 95 insertions(+), 81 deletions(-) diff --git a/applications/lazimageeditor/DLBitmap.pas b/applications/lazimageeditor/DLBitmap.pas index 71c9dd410..03a64f608 100644 --- a/applications/lazimageeditor/DLBitmap.pas +++ b/applications/lazimageeditor/DLBitmap.pas @@ -65,6 +65,7 @@ type procedure CopyToClipboard; virtual; procedure PasteFromClipboard; virtual; procedure Delete; virtual; + procedure FloodFill (x,y:integer); property FillColor: TColor read GetFillColor write SetFillColor; property OutlineColor: TColor read GetOutlineColor write SetOutlineColor; property PaperColor: TColor read GetPaperColor write SetPaperColor; @@ -363,6 +364,12 @@ begin tmp.Free; end; +procedure TDLBitmap.FloodFill (x, y:integer); +begin + Canvas.Brush.Color := FFillColor; + Canvas.FloodFill(x, y, Canvas.Pixels[x,y], fsSurface); +end; + procedure TDLBitmap.FillEllipse(X1, Y1, X2, Y2: integer); begin diff --git a/applications/lazimageeditor/bmprgbtypes.pas b/applications/lazimageeditor/bmprgbtypes.pas index c6dbb756c..76374a9b2 100644 --- a/applications/lazimageeditor/bmprgbtypes.pas +++ b/applications/lazimageeditor/bmprgbtypes.pas @@ -527,7 +527,8 @@ end; procedure TRGBBitmapCore.MaskFloodFill(X, Y: integer); begin Canvas.Brush.Color := clBlack; - Canvas.FillRect(Rect(0, 0, Width, Height)); +// Canvas.FillRect(Rect(0, 0, Width, Height)); + FloodFill(X, Y); end; // AAlpha is the alpha of the rectangle, ranging from diff --git a/applications/lazimageeditor/lazimageeditor.lpi b/applications/lazimageeditor/lazimageeditor.lpi index fa2d78f44..e69780f90 100644 --- a/applications/lazimageeditor/lazimageeditor.lpi +++ b/applications/lazimageeditor/lazimageeditor.lpi @@ -41,7 +41,7 @@ - + @@ -50,7 +50,7 @@ - + @@ -62,21 +62,20 @@ - - - + + + - - - - + + + @@ -172,8 +171,8 @@ - - + + @@ -183,7 +182,7 @@ - + @@ -245,19 +244,19 @@ - + - - - + + + - - - + + + @@ -278,38 +277,34 @@ - - - - - + + + - - - + + + - - @@ -364,11 +359,12 @@ + - - - + + + @@ -387,127 +383,135 @@ + + + + + + + + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - - + + - + diff --git a/applications/lazimageeditor/picturectrls.pas b/applications/lazimageeditor/picturectrls.pas index 955e99bf8..2e6cccbc2 100644 --- a/applications/lazimageeditor/picturectrls.pas +++ b/applications/lazimageeditor/picturectrls.pas @@ -763,7 +763,9 @@ begin BeginDraw; if not (ssLeft in Shift) then Picture.EraseMode := ermErase; try - Picture.Canvas.FloodFill(X, Y, FFillColor, fsSurface); //Picture.Canvas.Brush.Color, fsSurface); + //Picture.Canvas.FloodFill(X, Y, FFillColor, fsSurface); //Picture.Canvas.Brush.Color, fsSurface); + Picture.Canvas.Brush.Color := FFillColor; + Picture.Canvas.FloodFill(x, y, Picture.Canvas.Pixels[x,y], fsSurface); finally Picture.EraseMode := ermNone; EndDraw;