From 32dbf71e3a9b103ac98b7c978d53c040bcdc1288 Mon Sep 17 00:00:00 2001 From: marc Date: Tue, 31 Aug 2010 21:32:03 +0000 Subject: [PATCH] * add workaround for alpha channel on palette based PNG images for fpc2.4 (fixed in fpc r15926 #af088605bf). Fixes issue #0017267 git-svn-id: trunk@27242 - --- lcl/intfgraphics.pas | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lcl/intfgraphics.pas b/lcl/intfgraphics.pas index 0c7ccedfc4..36cd0141f0 100644 --- a/lcl/intfgraphics.pas +++ b/lcl/intfgraphics.pas @@ -5764,9 +5764,27 @@ begin end; procedure TLazReaderPNG.HandleAlpha; +{$ifdef VER2_4} +var + n: Integer; + c: TFPColor; +{$endif} begin inherited HandleAlpha; FAlphaPalette := Header.ColorType = 3; + + // check for fpc 2.4, it expands the alpha channel wrong, so the MSByte isn't set + {$ifdef VER2_4} + if not FAlphaPalette then Exit; + for n := 0 to ThePalette.Count - 1 do + begin + c := ThePalette[n]; + if c.Alpha and $FF00 <> 0 then Continue; + if c.Alpha = 0 then Continue; + c.Alpha := c.Alpha shl 8 or c.Alpha; + ThePalette[n] := c; + end; + {$endif} end; procedure TLazReaderPNG.InternalRead(Str: TStream; Img: TFPCustomImage);