summaryrefslogtreecommitdiff
path: root/src/corelib/fpg_base.pas
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/fpg_base.pas')
-rw-r--r--src/corelib/fpg_base.pas33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/corelib/fpg_base.pas b/src/corelib/fpg_base.pas
index a6f4947f..0da6cf25 100644
--- a/src/corelib/fpg_base.pas
+++ b/src/corelib/fpg_base.pas
@@ -19,6 +19,9 @@ unit fpg_base;
{$mode objfpc}{$H+}
+// To enable the AggPas powered Canvas
+{.$define AGGCanvas}
+
interface
uses
@@ -2271,11 +2274,12 @@ procedure TfpgImageBase.CreateMaskFromSample(x, y: TfpgCoord);
var
p: ^longword;
pmsk: ^byte;
- c: longword;
+ c, n: longword;
linecnt: integer;
pixelcnt: integer;
bit: byte;
msklinelen: integer;
+ row, col: integer;
begin
if FColorDepth = 1 then
Exit; //==>
@@ -2283,6 +2287,32 @@ begin
if (FImageData = nil) then
Exit; //==>
+{$ifdef AGGCanvas}
+ p := FImageData;
+ if x < 0 then
+ Inc(p, FWidth - 1)
+ else
+ Inc(p, x);
+ if y < 0 then
+ Inc(p, FWidth * (FHeight - 1))
+ else
+ Inc(p, FWidth * y);
+
+ c := p^; // the sample
+
+ for row := 0 to FHeight-1 do
+ begin
+ for col := 0 to FWidth-1 do
+ begin
+ n := PLongWord(FImageData)[row * FWidth + col];
+ if n = c then
+ { set Alpha value 100% transparent }
+ PLongWord(FImageData)[row * FWidth + col] := n and $00FFFFFF;
+ end;
+ end;
+
+{$else}
+
AllocateMask;
FMaskPoint := Point(x, y);
@@ -2334,6 +2364,7 @@ begin
Inc(linecnt);
until linecnt >= FHeight;
+{$endif}
end;
procedure TfpgImageBase.UpdateImage;