Ping! Another one fully cooked
Posted by Steve Revill Fri, 13 Aug 2021 16:21:00 GMT
Portable Network Graphics, with file extension PNG and often pronounced Ping, is a common bitmap graphics format which offers lossless compression for faster transfer over the internet. PNG sits somewhere between Sprite, which is uncompressed, and JPEG used for photos, which uses lossy compression (throwing some information away) to shrink the file even smaller.
What do we gain?
There are two aspects to the new PNG support:
- Being able to save directly from Paint as a PNG graphic
- Being able to convert anything ChangeFSI can open and write it out as a PNG graphic
Underneath this there’s a new support module, called CompressPNG, which does the real work and which other applications will be able to make use of.
If you are a developer and you’d like to add PNG export to one of your own applications it’s simply a case of making a few system calls from whatever language you prefer to use. It’s very similar to the CompressJPEG module which has shipped since RISC OS 3.60, so much so that Paint has also gained the ability to save out as JPEG via that same approach.
It all starts with a bounty
These new features are just one in a long line of bounties backed by the community. Take a look at the current clutch for inspiration.
How to get hold of the updated apps
You’ll need to update your !System from the “beta” HardDisc4 download, in particular to add the CompressPNG support module. The associated version of ChangeFSI 1.65 is in the Utilities directory of that download.
Paint 2.41 is currently built into all of the RISC OS 5 ROMs, so if you update your computer to one of those you’ll have Paint on hand. If you’re not ready for a ROM update, there’s a disc based copy tucked away in !Boot.RO350Hook.Apps.!Paint in the same HardDisc4 download that you got CompressPNG and ChangeFSI from.
I used this today and it did the trick :)
But… if PNG is lossless, what’s the “Compression” value for?
This is not my field so I stand to be corrected but…
The compression value is for controlling the amount of compression performed. With a losy codec you control this in order to obtain more fidelity at the cost of larger file size.
For a lossless codec like PNG the reasons are different. Remember that version 1.0 of the PNG standard emerged in 1996. Think about how much processing power and memory computers of that era had. Controlling the amount of compression allows you to control how much memory and how long it will take to code and, more importantly, decode the image.
These days we would probably just wind it up to 9 and leave it there.
It could be nice if PNG output could retain Sprite transparency.
Saving from Paint preserves transparency, go ahead and try it.
Saving via calls (eg. from BASIC) to CompressPNG also preserves transparency, go ahead and try it.
ChangeFSI doesn’t support transparency of any format, not even Sprites.
Nicely done!
You can see the transparency if you load the PNG with PrivateEye.