+ True Color fixes in FloodFill

git-svn-id: trunk@40867 -
This commit is contained in:
nickysn 2019-01-14 17:13:07 +00:00
parent b68567f1d9
commit 54d2e1ca1c

View File

@ -297,6 +297,11 @@ var
End; End;
s1, s2, s3 : PWordArray; { Three buffers for scanlines } s1, s2, s3 : PWordArray; { Three buffers for scanlines }
{$ifdef FPC_GRAPH_SUPPORTS_TRUECOLOR}
sl1 : PLongWordArray absolute s1;
sl2 : PLongWordArray absolute s2;
sl3 : PLongWordArray absolute s3;
{$endif FPC_GRAPH_SUPPORTS_TRUECOLOR}
Procedure PushPoint (x, y : smallint); Procedure PushPoint (x, y : smallint);
@ -437,9 +442,20 @@ var
BackupColor := CurrentColor; BackupColor := CurrentColor;
CurrentColor := FillSettings.Color; CurrentColor := FillSettings.Color;
{ MaxX is based on zero index } { MaxX is based on zero index }
GetMem (s1,(ViewWidth+1)*2); { A pixel color represents a word } {$ifdef FPC_GRAPH_SUPPORTS_TRUECOLOR}
GetMem (s2,(ViewWidth+1)*2); { A pixel color represents a word } if MaxColor > 65536 then
GetMem (s3,(ViewWidth+1)*2); { A pixel color represents a word } begin
GetMem (s1,(ViewWidth+1)*4); { A pixel color represents a word }
GetMem (s2,(ViewWidth+1)*4); { A pixel color represents a word }
GetMem (s3,(ViewWidth+1)*4); { A pixel color represents a word }
end
else
{$endif FPC_GRAPH_SUPPORTS_TRUECOLOR}
begin
GetMem (s1,(ViewWidth+1)*2); { A pixel color represents a word }
GetMem (s2,(ViewWidth+1)*2); { A pixel color represents a word }
GetMem (s3,(ViewWidth+1)*2); { A pixel color represents a word }
end;
if (not assigned(s1)) or (not assigned(s2)) or (not assigned(s3)) then if (not assigned(s1)) or (not assigned(s2)) or (not assigned(s3)) then
begin begin
_GraphResult := grNoFloodMem; _GraphResult := grNoFloodMem;
@ -485,38 +501,82 @@ var
end; end;
prevy := y; prevy := y;
{ check the current scan line } { check the current scan line }
While (s1^[x]<>Border) And (x<=ViewWidth) Do Inc (x); {$ifdef FPC_GRAPH_SUPPORTS_TRUECOLOR}
if MaxColor > 65536 then
begin
While (sl1^[x]<>Border) And (x<=ViewWidth) Do Inc (x);
end
else
{$endif FPC_GRAPH_SUPPORTS_TRUECOLOR}
begin
While (s1^[x]<>Border) And (x<=ViewWidth) Do Inc (x);
end;
d:=0; d:=0;
e:=0; e:=0;
dec(x); dec(x);
Beginx:=x; Beginx:=x;
REPEAT {$ifdef FPC_GRAPH_SUPPORTS_TRUECOLOR}
{ check the above line } if MaxColor > 65536 then
If y<ViewHeight then begin
Begin REPEAT
Cont:=(s3^[x]<>Border) and (not AlreadyDrawn(x,y+1)); { check the above line }
If (e=0) And Cont then If y<ViewHeight then
Begin
Cont:=(sl3^[x]<>Border) and (not AlreadyDrawn(x,y+1));
If (e=0) And Cont then
Begin
PushPoint (x,y+1);
e:=1;
End
Else
If (e=1) And Not Cont then e:=0;
End;
{ check the line below }
If (y>0) then
Begin
Cont:=(sl2^[x]<>Border) and (not AlreadyDrawn(x,y-1));
If (d=0) And Cont then
Begin Begin
PushPoint (x,y+1); PushPoint (x,y-1);
e:=1; d:=1;
End End
Else Else
If (e=1) And Not Cont then e:=0; If (d=1) And Not Cont then d:=0;
End; End;
{ check the line below } Dec (x);
If (y>0) then Until (x<0) Or (sl1^[x]=Border);
Begin end
Cont:=(s2^[x]<>Border) and (not AlreadyDrawn(x,y-1)); else
If (d=0) And Cont then {$endif FPC_GRAPH_SUPPORTS_TRUECOLOR}
Begin begin
PushPoint (x,y-1); REPEAT
d:=1; { check the above line }
End If y<ViewHeight then
Else Begin
If (d=1) And Not Cont then d:=0; Cont:=(s3^[x]<>Border) and (not AlreadyDrawn(x,y+1));
End; If (e=0) And Cont then
Dec (x); Begin
Until (x<0) Or (s1^[x]=Border); PushPoint (x,y+1);
e:=1;
End
Else
If (e=1) And Not Cont then e:=0;
End;
{ check the line below }
If (y>0) then
Begin
Cont:=(s2^[x]<>Border) and (not AlreadyDrawn(x,y-1));
If (d=0) And Cont then
Begin
PushPoint (x,y-1);
d:=1;
End
Else
If (d=1) And Not Cont then d:=0;
End;
Dec (x);
Until (x<0) Or (s1^[x]=Border);
end;
{ swap the values } { swap the values }
x1:=x+1; x1:=x+1;
x2:=BeginX; x2:=BeginX;
@ -531,9 +591,20 @@ var
PatternLine (x1,x2,y); PatternLine (x1,x2,y);
End; { end while } End; { end while }
System.FreeMem (s1,(ViewWidth+1)*2); {$ifdef FPC_GRAPH_SUPPORTS_TRUECOLOR}
System.FreeMem (s2,(ViewWidth+1)*2); if MaxColor > 65536 then
System.FreeMem (s3,(ViewWidth+1)*2); begin
System.FreeMem (s1,(ViewWidth+1)*4);
System.FreeMem (s2,(ViewWidth+1)*4);
System.FreeMem (s3,(ViewWidth+1)*4);
end
else
{$endif FPC_GRAPH_SUPPORTS_TRUECOLOR}
begin
System.FreeMem (s1,(ViewWidth+1)*2);
System.FreeMem (s2,(ViewWidth+1)*2);
System.FreeMem (s3,(ViewWidth+1)*2);
end;
CleanUpDrawnList; CleanUpDrawnList;
System.FreeMem(DrawnList,sizeof(PFloodLine)*((ViewHeight div YResDiv) + 1)); System.FreeMem(DrawnList,sizeof(PFloodLine)*((ViewHeight div YResDiv) + 1));
CurrentColor := BackUpColor; CurrentColor := BackUpColor;