Silverfrost Forums

Welcome to our forums

PNG transparency

10 Oct 2022 4:16 #29416

Is it possible to add a transparency layer when creating PNG files?

Norm Campbell

10 Oct 2022 7:49 #29417

Try seaching Google for 'png with transparent background'.

If you are programming a ClearWin+ application that exports a png file then perhaps you need to add opacity to the image. Try searching in ftn95.chm for 'opacity'.

10 Oct 2022 8:38 #29419

I should have been more explicit.

Currently I have a work-around, where I load the JPG images into Photoshop; define a 'transparent' area; and export the resulting edited images as PNGs.

This has been fine for the occasional PNG file, but now I'm looking at quite a number of yield map images with non-rectangular boundaries, all of which need editing.

What I'd like to be able to do is use something like PUT_DIB_BLOCK (which I use now to write my JPGs) to write a 24-bit PNG file, where the 4th byte is the transparency layer.

10 Oct 2022 9:22 #29421

PUT_DIB_BLOCK@ can currently be used to export bmp or jpeg files but not png files.

In theory it could be extended to png files but off hand I don't know how big a task that would be.

EXPORT_IMAGE@ can be used with png files so that provides a possible alternative.

10 Oct 2022 10:28 #29422

I read that PUT_DIB_BLOCK worked for PNG files, so I changed the extension, and my code wrote a PNG file.

The resulting PNG file (according to its properties) is 24-bit, and displays when I click on it.

It opens in Paint, but not in Photoshop CS4.

10 Oct 2022 10:59 #29424

I can't see any evidence in the documentation or the code to suggest that PUT_DIB_BLOCK@ supports png files.

I am guessing that the output is the same as for a bmp file and that some applications can tell the difference.

10 Oct 2022 11:59 #29425

You guessed correctly.

My code only appears to write a PNG file because I gave the file name a PNG extension.

When I renamed the output 'PNG' file as .BMP, CS4 recognised it (as did Paint).

Please login to reply.