[lazarus] started porting Delphi PNG unit to FPC/Lazarus

Stefan Weber w-e-b-e-r at web.de
Sat Jun 28 10:55:42 EDT 2003


I've started porting the native Delphi PNG sources available at
http://pngdelphi.sourceforge.net/pngimage143.zip.
The unit compiles with FPC after applying the diff from the attachment.
(The source is freeware, but I cannot distribute the modified source 
without permisson from the author.)

It is possible to load and save PNG Images, but the drawing functions do
not work. This is due to the lack of support for DIB-related Windows API
functions in the LCL. Those functions are not yet implemented. I've
tried a little to find a simple way to assign the png to a bitmap but
failed.

Finally I've used a simple loop to draw the picture inside TPaintBox.Paint:

    for y := 0 to png.Height - 1 do
      for x := 0 to png.Width - 1 do
        aCanvas.Pixels[x,y] := png.Pixels[x,y];

While trying to draw to an offscreen TBitmap, I found that setting
Pixels does not work if there's no Widget associated with the Bitmap

Since I don't have the time to work on this in the next days, I decided
to post the source ... maybe one of you wants to give it a try?

My test source is included with this mail.

Probably it would be better to get the LCL DIB stuff working instead of
trying to work around it ... what do you think?

-Stefan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gz00025.gz
Type: application/octet-stream
Size: 18042 bytes
Desc: "pngimage.tar.gz"
Url : http://localhost/pipermail/lazarus/attachments/20030628/7b857002/gz00025.obj


More information about the Lazarus mailing list