silvioprog <[email protected]> hat am 5. Februar 2013 um 16:08 geschrieben:
> 2013/2/5 Mattias Gaertner <[email protected] > <mailto:[email protected]> > > > > On Tue, 5 Feb 2013 12:37:24 -0200 > > silvioprog < [email protected] <mailto:[email protected]> > 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. c.Alpha, c.Blue are word, not byte. BTW, reading and writing to/from Filestream should be done in chunks, not in bytes. That's dog slow. Use a TMemoryStream as cache. Mattias _______________________________________________ fpc-devel maillist - [email protected] http://lists.freepascal.org/mailman/listinfo/fpc-devel
