Introduction and Overview
The PNG module supplies a shared interface to the PNG library. Due to the work of many developers, including Acorn, the PNG library is quite generic and can produce its output or read its input in a number of ways.
Technical Details
In general the SWI interface is exactly the same as that of the PNG library. When there is time this will be documented more formally, but the general principles are :
- Functions are split into categories which are accessed via SWIs.
- Each SWI has R0 giving the sub-code for the function being accessed. [Reason: There's not enough SWIs in a chunk for all of the functions to have one each]
- Input values are in the registers going into the SWI. Return values come out in R0. Output values are in the registers coming out of the SWI at the next free register (R0 if there is a return parameter, or R1 if not).
- Floating point values are returned (or passed) scaled by &10000 (ie converted to fixed point values with the point at bit 16).
Example
The library function:
png_uint_32 png_get_gAMA (png_structp png_ptr, png_infop info_ptr, double *file_gamma) ;
Becomes the SWI SWI PNG_GetChunkInfo, with R0 set to 2 (the reason code for get_gAMA).
Caveats
The cHRM (chromaticity) chunk is not currently supported. The implementation is such that this cannot work the way that the SWI interface is currently designed.
More information
Firstly, you should read the documentation supplied with PNGLib. This will provide you with most of the necessary information. More information, together with a development kit, is available on request.
SWI Calls
| R0 | = | 2 (reason code for get_gAMA) |
| R1 | = | Pointer to png structure returned from create_read_struct |
| R2 | = | Pointer to png information structure returned from png_create_info_struct |
| R0 | = | Returned value (0 if no gAMA chunk, non-0 if gAMA chunk present) |
| R1 | = | Gamma value * &10000 |
This SWI is given as an example of the way in which the functions of the PNG library are made available. The reason code in R0 selects the function.