[fpc-devel] Extract the color data and alpha from a PNG image
Mattias Gaertner
nc-gaertnma at netcologne.de
Tue Feb 5 15:48:12 CET 2013
On Tue, 5 Feb 2013 12:37:24 -0200
silvioprog <silvioprog at gmail.com> wrote:
> Hello friends,
>
> I'm trying to extract the color data and alpha from a PNG image. In PHP it
> is very easy to implement, but in FPC I don't know how to do it. I tried to
> do it via "chunk.data", "ZData" etc., but, without success.
>
> Attached two files to test it. To test the PHP code run this command in
> your terminal:
>
> php -f fpdf.php
>
> The in FPC code is partially complete.
Have you tried fpimage?
uses
fpreadpng, fpimage;
var
image: TFPCustomImage;
reader: TFPCustomImageReader;
x,y: integer;
c: TFPColor;
begin
Image := TFPMemoryImage.Create(0, 0);
Reader := TFPReaderPNG.Create;
Image.LoadFromFile(AFileName, Reader);
for y:=0 to Image.Height-1 do
for x:=0 to Image.Width-1 do begin
c:=Image.Colors[x,y];
writeln(c.Alpha,' ',c.Blue);
end;
//...
Mattias
More information about the fpc-devel
mailing list