Skip to content

Commit 17b94a1

Browse files
committed
TSimbaImage tweaks
1 parent 5cf0520 commit 17b94a1

File tree

8 files changed

+246
-202
lines changed

8 files changed

+246
-202
lines changed

Source/image/clearpixelaa.inc renamed to Source/image/clearpixelalpha.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
procedure _ClearPixelA(const X, Y: Integer; const Alpha: Byte); inline;
1+
procedure _SetPixelAntialias(const X, Y: Integer; const Alpha: Byte); inline;
22
begin
33
if (X >= 0) and (Y >= 0) and (X < FWidth) and (Y < FHeight) then
44
FData[Y*FWidth+X].A := 0;

Source/image/drawellipseaa.inc renamed to Source/image/ellipseantialias.inc

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// https://zingl.github.io/bresenham.js
2+
// Requires _SetPixelAntialias(const X, Y: Integer; const Alpha: Byte);
23

3-
procedure _DrawEllipseAA(x0, y0, x1, y1: Integer; Thickness: Single);
4+
procedure _EllipseAntialias(x0, y0, x1, y1: Integer; Thickness: Single);
45
var
56
a,b,b1: Integer;
67
a2,b2: Single;
@@ -76,10 +77,10 @@ begin
7677
i := 255*err/ed;
7778

7879
Alpha := Byte(Round(i));
79-
_SetPixelA(x0,y0, Alpha);
80-
_SetPixelA(x0,y1, Alpha);
81-
_SetPixelA(x1,y0, Alpha);
82-
_SetPixelA(x1,y1, Alpha);
80+
_SetPixelAntialias(x0,y0, Alpha);
81+
_SetPixelAntialias(x0,y1, Alpha);
82+
_SetPixelAntialias(x1,y0, Alpha);
83+
_SetPixelAntialias(x1,y1, Alpha);
8384

8485
if (err+dy+a < dx) then
8586
begin
@@ -95,10 +96,10 @@ begin
9596

9697
while (i < Thickness) and (2*i <= x0+x1) do
9798
begin
98-
_SetPixelA(Round(i), y0, 0);
99-
_SetPixelA(Round(x0+x1-i), y0, 0);
100-
_SetPixelA(Round(i), y1, 0);
101-
_SetPixelA(Round(x0+x1-i), y1, 0);
99+
_SetPixelAntialias(Round(i), y0, 0);
100+
_SetPixelAntialias(Round(x0+x1-i), y0, 0);
101+
_SetPixelAntialias(Round(i), y1, 0);
102+
_SetPixelAntialias(Round(x0+x1-i), y1, 0);
102103

103104
i += 1.0;
104105
end;
@@ -114,10 +115,10 @@ begin
114115
ed += 2*ed*i*i/(4*ed*ed+i*i);
115116

116117
Alpha := Byte(Round(255-255*e2/ed));
117-
_SetPixelA(Round(Thickness), y0, Alpha);
118-
_SetPixelA(Round(x0+x1-Thickness), y0, Alpha);
119-
_SetPixelA(Round(Thickness), y1, Alpha);
120-
_SetPixelA(Round(x0+x1-Thickness), y1, Alpha);
118+
_SetPixelAntialias(Round(Thickness), y0, Alpha);
119+
_SetPixelAntialias(Round(x0+x1-Thickness), y0, Alpha);
120+
_SetPixelAntialias(Round(Thickness), y1, Alpha);
121+
_SetPixelAntialias(Round(x0+x1-Thickness), y1, Alpha);
121122

122123
if (e2+dy2+a2 < dx2) then
123124
Break;
@@ -139,13 +140,13 @@ begin
139140
begin
140141
Alpha := Byte(Round(255*4*err/b1));
141142

142-
_SetPixelA(x0, y0, Alpha);
143-
_SetPixelA(x1, y0, Alpha);
143+
_SetPixelAntialias(x0, y0, Alpha);
144+
_SetPixelAntialias(x1, y0, Alpha);
144145

145146
y0 += 1;
146147

147-
_SetPixelA(x0, y1, Alpha);
148-
_SetPixelA(x1, y1, Alpha);
148+
_SetPixelAntialias(x0, y1, Alpha);
149+
_SetPixelAntialias(x1, y1, Alpha);
149150

150151
y1 -= 1;
151152
dy += a;

Source/image/drawlineaa.inc renamed to Source/image/lineantialias.inc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// https://zingl.github.io/bresenham.js
2+
// Requires _SetPixelAntialias(const X, Y: Integer; const Alpha: Byte);
23

3-
procedure _DrawLineAA(x0, y0, x1, y1: Integer; Thickness: Single);
4+
procedure _LineAntialias(x0, y0, x1, y1: Integer; Thickness: Single);
45
var
56
dx, dy, err: Integer;
67
e2, x2, y2: Integer;
@@ -22,7 +23,7 @@ begin
2223
Thickness := (Thickness + 1) / 2;
2324
while True do
2425
begin
25-
_SetPixelA(x0, y0, Round(Max(0, 255 * (Abs(err-dx+dy)/ed-Thickness+1))));
26+
_SetPixelAntialias(x0, y0, Round(Max(0, 255 * (Abs(err-dx+dy)/ed-Thickness+1))));
2627

2728
e2 := err;
2829
x2 := x0;
@@ -33,7 +34,7 @@ begin
3334
while (e2 < ed*Thickness) and ((y1 <> y2) or (dx > dy)) do
3435
begin
3536
y2 += sy;
36-
_SetPixelA(x0, y2, Round(Max(0, 255 * (Abs(e2)/ed-Thickness+1))));
37+
_SetPixelAntialias(x0, y2, Round(Max(0, 255 * (Abs(e2)/ed-Thickness+1))));
3738
e2 += dx;
3839
end;
3940
if (x0 = x1) then
@@ -50,7 +51,7 @@ begin
5051
while (e2 < ed*Thickness) and ((x1 <> x2) or (dx < dy)) do
5152
begin
5253
x2 += sx;
53-
_SetPixelA(x2, y0, Round(Max(0, 255 * (Abs(e2)/ed-Thickness+1))));
54+
_SetPixelAntialias(x2, y0, Round(Max(0, 255 * (Abs(e2)/ed-Thickness+1))));
5455
e2 += dy;
5556
end;
5657
if (y0 = y1) then

Source/image/setpixel.inc

Lines changed: 0 additions & 6 deletions
This file was deleted.

Source/image/drawpixelaa.inc renamed to Source/image/setpixelantialias.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
procedure _SetPixelA(const X, Y: Integer; const Alpha: Byte); inline;
1+
procedure _SetPixelAntialias(const X, Y: Integer; const Alpha: Byte); inline;
22
var
33
Pixel: PColorBGRA;
44
APlus1, APlus1Inv: UInt32;

0 commit comments

Comments
 (0)