Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-06

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

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bernd

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

Reply by email