JPEGs, GIFs and PNGs

Had an email today from the author of the Photon JPEG graphics viewer, David Westbury.

It contained the latest incarnation of his graphics conversion programs, FJpeg, FGif and now FPng as well.

These routines are written as SuperBASIC extension functions to decode JPEG, GIF and PNG graphics files to QL PIC format graphic files, in the GD2 (“colour drivers”) modes.

To use the conversion routines in your own QL BASIC programs, just use a line of BASIC like this:

error% = FPNG(inputfile$,outputfile$,dmode%)

The value returned into the variable error% is a standard QL error code if non-zero, while a value of zero indicates no error occurred. You specify the filename of the original graphics file in ‘inputfile$’, the filename of the QL PIC file to be generated in ‘outputfile$’ and the GD2 mode number of the QL PIC file generated in dmode% (listed in the text files with the extensions if you don’t know them, e.g. 32 for 16-bit colour on QPC2 and QXL, 16 for 256-colour modes on QPC2 and Aurora and 33 for Q40/Q60 16-bit colour mode). Be aware that QL PIC files are uncompressed so you may unwittingly generate very large QL graphics files. To help with this, there is a second extension function, which is used to estimate the size of the file to be produced:

filesize = MPNG(inputfile$,dmode%)

A positive value indicates the maximum size of the file, while a negative value is a standard error code. This second extension has an extra trick up its sleeve if you give the mode number as -1, when filesize will return with the screen dimensions returned in the lower and upper 16 bits of the 32-bit value returned.

Separate extensions are provided for JPEG, GIF and PNG files – called FJPEG, FGIF and FPNG respectively along with FMJPEG, FMGIF and FMPNG.

Support BASIC programs are included to return the esoteric information on the source graphic files, along with a program called wallpaper_bas which can be used to produce BGIMAGE wallpaper background images for use with the BGIMAGE command in SBASIC.

Describing why the functions were written as individual functions, the author says: “They were developed in that form (rather than executable jobs) to facilitate debugging and running a batch job on sample files” and “Enhanced versions of the code will be used in an update to my Photon graphics utility (which can be used as a job or made resident).

Thanks to David Westbury we now have simple to use extensions to help write graphics conversion and viewing programs for the QL now that high colour QL systems are pretty common on the QL scene.

Download the software freeof charge from the Graphics page on my website at http://www.dilwyn.me.uk/graphics/index.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s