[fpc-devel] Extract the color data and alpha from a PNG image
silvioprog
silvioprog at gmail.com
Tue Feb 5 16:08:42 CET 2013
2013/2/5 Mattias Gaertner <nc-gaertnma at netcologne.de>
> 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
Yes, I tried it too, but, without success. :(
See my new code in attached. It generates the data, but with wrong content.
--
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130205/989f9ade/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fpc-20130205-1307.zip
Type: application/zip
Size: 42452 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130205/989f9ade/attachment.zip>
More information about the fpc-devel
mailing list