Introduction
The ImageFileConvert module provides an interface for converting between different image formats through a simple defined interface. Whilst this interface may not be perfectly suited to all image formats, it can be extended through flagged operations to provide greater flexibility and to allow more functional conversions to be made.
Because ImageFileConvert and ImageFileRender complement one another it is recommended that users of either familiarise themselves with the other.
Technical Details
Flags common to output type 'Sprite'
Because Sprite is a common type to convert to a number of flags are defined as being used for all conversions.
| Bit(s) | Meaning | |
|---|---|---|
| 0 | Create a sprite, rather than a sprite file (this option is provided by the ImageFileConvert module) | |
| 1-7 | Reserved | |
Flags common to output type 'JPEG'
Because JPEG is a common type to convert to a number of flags are defined as being used for all conversions.
| Bit(s) | Meaning | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Output JPEG will be monochrome (otherwise it will be colour) | |||||||||||||||||||
| 1-3 | Quality control:
| |||||||||||||||||||
| 4-7 | Reserved | |||||||||||||||||||
The duplication of 75% in both 0 and 6 is to allow users to leave the flags unset and get a sensible default conversion quality.
Flags common to input type 'Sprite'
Although sprite is a common filetype to convert from none of the flags are reserved for all conversions.
| Bit(s) | Meaning | |
|---|---|---|
| 8-15 | Reserved | |
Operations common to the output type 'Sprite'
The following operation is provided by SWI ImageFileConvert_MiscOp for conversions to the output type 'Sprite'.
On entry:
R4 = &400 (Read information)
R5-R9 undefined
On exit:
| Offset | Contents |
|---|---|
| R0 | Width in pixels of image |
| R1 | Height in pixels of image |
| R2 | Bits per pixel in the image |
| R3 | Image flags (see below) |
| R4 | X DPI |
| R5 | Y DPI |
The image flags in R3 are:
| Bit(s) | Meaning | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Image has a palette (if <=8bpp) | |||||||||||
| 1 | Image is colour (otherwise image is greyscale) | |||||||||||
| 2 | Image has alpha channel or mask | |||||||||||
| 3-5 | Interlace type:
| |||||||||||
| 6-31 | Reserved | |||||||||||
This operation reads information about the image which is common to most bitmap-type operations.
SWI Calls
| R0 | = | Flags for operation:
| |||||||||||||||
| R1 | = | Conversion requested:
| |||||||||||||||
| R2 | = | Pointer to input image data | |||||||||||||||
| R3 | = | Length of input image data | |||||||||||||||
| R4 | = | Pointer to output image buffer, or 0 to read size | |||||||||||||||
| R5 | = | Size of output image buffer, or 0 to read size | |||||||||||||||
| R6 | = | Background colour, or -1 for default (may be ignored by some converters) | |||||||||||||||
| R7 - R9 | = | Passed to conversion process | |||||||||||||||
| R5 | = | Size of output image buffer required, or -1 if not known (if R4 = 0 on entry), size of output image buffer used (if R4 not 0 on entry) |
This SWI is used to convert an image from one format to another.
| R0 | = | Flag bits:
| |||||||||||||||
| R1 | = | Conversion requested:
| |||||||||||||||
| R2 | = | Pointer to input image data | |||||||||||||||
| R3 | = | Length of input image data | |||||||||||||||
| R4 | = | Operation type:
| |||||||||||||||
| R5 - R9 | = | Misc op parameters | |||||||||||||||
| R0 - R9 | = | Updated by conversion module |
This SWI is used to provide miscellaneous operations to obtain information about the conversion process.
| R0 | = | Flags (reserved, must be 0) | |||||||||||||||||||||||||||||||
| R1 | = | Pointer to definition (all will be copied):
| |||||||||||||||||||||||||||||||
| R1 | = | API version (even if an error occurs) |
| R0,2 - R9 | = | Preserved |
This SWI is used to register a new converter.
| R0 | = | Flags (reserved, must be 0) |
| R1 | = | Filetype pair |
| R2 | = | Pointer to name to be copied, in the format <name><tab><version x.xx><tab><author> |
| R0 - R2 | = | Preserved |
This SWI is used to deregister a converter.
| R0 | = | Flags (reserved, must be 0) |
| R1 | = | Last filetype pair, or -1 for the first call |
| R0 | = | Pointer to renderer definition (read only) |
| R1 | = | This filetype pair, or -1 if no more |
This SWI is used to enumerate the currently registered converters.
| R0 | = | Flags (reserved, must be 0) |
| R1 | = | Filetype pair |
| R0 | = | Pointer to renderer definition (read only) |
| R1 | = | Pointer to renderer name |
This SWI is used to read information on a conversion. If no conversion can be performed for the requested types, an error will be returned.