JPEG, GIF and PNG file conversion

Anything QL Software or Programming Related.
Post Reply
User avatar
dilwyn
Mr QL
Posts: 3065
Joined: Wed Dec 01, 2010 10:39 pm

JPEG, GIF and PNG file conversion

Post by dilwyn »

Thanks to the author of the Photon software, we now have simple to use BASIC extensions which can convert JPEG, GIF and PNG graphics files to QL PIC files on GD2 colour QL compatible systems, making it easier to write QL graphics and viewer programs with simple SBASIC.

The extensions are available to download free of charge from the Graphics page on my website at http://www.dilwyn.me.uk/graphics/index.html (scroll down to the section just under the entry for 'Photon')

I've written a short article about it on my QL blog at https://dilwyn2.wordpress.com/


Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

Re: JPEG, GIF and PNG file conversion

Post by Silvester »

Thanks Dilwyn. Now have I completed the most used formats (glad I didn't do TIFF now!), I can finish Photon. Current Web statistics on image formats at :

http://w3techs.com/technologies/overvie ... format/all


David
User avatar
BSJR
Trump Card
Posts: 220
Joined: Sun Oct 18, 2015 12:53 pm
Location: Amsterdam
Contact:

Re: JPEG, GIF and PNG file conversion

Post by BSJR »

Thank you Silvester for making these tools, and Dilwyn for distributing.
A quick test shows that it's working very well on QPC2 and much faster then the 'C' based options I used before.
Once I have finalized the addition to my SQRview viewer I will also test it on Aurora but do not expect any problems there because all modes work well on QPC2 and SMSQmulator.
It proves the power of compression. I have one .gif of less than 200KB which will expand to about 13MB of _pic files for all 26 frames!

One question though. In the PNG text there is also a line about the frame% parameter but the FPNG command does'nt accept this parameter. Do PNG's have multi-frames or has this line been copied there by mistake?

BSJR


Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

Re: JPEG, GIF and PNG file conversion

Post by Silvester »

>frame% parameter but the FPNG command doesn't accept this parameter.

Yes, this should have been removed (just re-wrote GIF text).

PNG does do a multi-frame format APNG, but it is not widely supported (you'd be lucky to find many files). AFAIK, Firefox browser supports it, IE doesn't ! Most web pages resort to using GIF for animated/short videos.

There is a lot more to PNG (Gamma etc) which also is rarely used. Perhaps when the base version of Photon is covered I can look at other details. Also have a few optimisations to improve speed (Oh for a 1GHz 68000).


David
User avatar
BSJR
Trump Card
Posts: 220
Joined: Sun Oct 18, 2015 12:53 pm
Location: Amsterdam
Contact:

Re: JPEG, GIF and PNG file conversion

Post by BSJR »

>frame% parameter but the FPNG command doesn't accept this parameter.

Yes, this should have been removed (just re-wrote GIF text).
Thanks Silvester for clearing that up.
There is a lot more to PNG (Gamma etc) which also is rarely used. Perhaps when the base version of Photon is covered I can look at other details. Also have a few optimisations to improve speed (Oh for a 1GHz 68000).
You also mentioned skipping transparency in PNG for now because the PIC format does not support it. But I think this is a nice opportunity to use/promote the Extended Sprite format with alpha and convert directly to that. Maybe an extra flag/parameter can be used to choose PIC or SPR output

This SPR format could also be an option for multi-frame GIFs. I may attempt to convert my 26 frames example into a SPR and see what RLE compression can shave off the 13MB of raw data.
Although once loaded in QPC it will probably unpack to the full amount.

BSJR


Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

Re: JPEG, GIF and PNG file conversion

Post by Silvester »

Yes, I was tempted to exploit spare byte in PIC header to add features, but thought I'd wait until other things are resolved: RGB format may should have been long word (I did 3 bytes), what was the spare byte to be, 0? (could be Alpha). Should line be rounded up to long word?, what are spare pixels padded with? WSA areas in EasyPtr are long word length, etc, etc...

The functions where just basis for solving decode. An extended PIC format needs to be discussed in detail. It would have been too easy to invent something which would restrict options later.


David
User avatar
dilwyn
Mr QL
Posts: 3065
Joined: Wed Dec 01, 2010 10:39 pm

Re: JPEG, GIF and PNG file conversion

Post by dilwyn »

Silvester wrote:Yes, I was tempted to exploit spare byte in PIC header to add features, but thought I'd wait until other things are resolved: RGB format may should have been long word (I did 3 bytes), what was the spare byte to be, 0? (could be Alpha). Should line be rounded up to long word?, what are spare pixels padded with? WSA areas in EasyPtr are long word length, etc, etc...

The functions where just basis for solving decode. An extended PIC format needs to be discussed in detail. It would have been too easy to invent something which would restrict options later.
Q-Design implements a form of file compression of PIC page files, flagged by varying the unused byte in the 10 byte PIC file preamble. I'm afraid I don't have documentation or example files to know what the file format or even flag value is.
I suppose the obvious way of implementing compression would be to make it the same as the GD2 sprite RLE compression, although as you say needs to be discussed in detail.


User avatar
QLvsJAGUAR
Gold Card
Posts: 485
Joined: Tue Feb 15, 2011 8:42 am
Location: Lucerne, Switzerland
Contact:

Re: JPEG, GIF and PNG file conversion

Post by QLvsJAGUAR »

I'm very much looking forward for the improved Photon, Dave.


QL forever!
https://www.sinclairql.net/ - Go and get THE DISTRIBUTION & QL/E!
https://www.youtube.com/QLvsJAGUAR/community - Blog
https://www.youtube.com/QLvsJAGUAR - Dedicated QL videos
Sinclair, QL, ATARI, JAGUAR, NUON, APPLE, NeXT, MiST & much more...
Videos, pictures & information
Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

Re: JPEG, GIF and PNG file conversion

Post by Silvester »

QLvsJAGUAR wrote:I'm very much looking forward for the improved Photon, Dave.
It's taking longer than expected. I had to do GIF and PNG first (from first principles) before I embarked on writing the common routines. Just as well, if I had gone ahead with a RGB output model for all the routines it would have made GIF and PNG decoding a great deal slower. Some of things I hope to do have yet to be proven (so resisted posting features), some already work on some platforms, but not all.


David
Post Reply