[fpc-pascal] [Patch] there is a small bug in fcl-image imterpolation

Bernd prof7bit at googlemail.com
Sat Jun 9 16:58:32 CEST 2012


in packages/fcl-image/src/fpinterpolation.inc when it calculates the
interpolated color it must initialize the value of the variable NewCol
with a quadruple of all zero but it actually uses colBlack which has
RGB set to zero but alpha is $ffff. This is wrong. It makes it
impossible to scale any image with alpha channel (the colors are fine
but the alpha channel will be messed up completely.

This patch fixes it:

Index: packages/fcl-image/src/fpinterpolation.inc
===================================================================
--- packages/fcl-image/src/fpinterpolation.inc	(Revision 21487)
+++ packages/fcl-image/src/fpinterpolation.inc	(Arbeitskopie)
@@ -179,7 +179,7 @@
         begin
           sx:=PInteger(xEntry)^;
           inc(xEntry,SizeOf(integer));
-          NewCol:=colBlack;
+          NewCol:= colTransparent;
           for cx:=0 to xSupport-1 do
           begin
             f:=PSingle(xEntry)^;
@@ -198,7 +198,7 @@
       for dx:=0 to w-1 do
       begin
         CurEntry:=yEntry+SizeOf(integer);
-        NewCol:=colBlack;
+        NewCol:=colTransparent;
         for sy:=0 to ySupport-1 do
         begin
           f:=PSingle(CurEntry)^;


Instead of starting with colBlack which is (0,0,0,$ffff) it must start
with colTransparent which is (0,0,0,0)

After applying this patch I can now properly scale images with alpha channel.

Bernd



More information about the fpc-pascal mailing list