ImageFileConvert

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
0Create a sprite, rather than a sprite file (this option is provided by the ImageFileConvert module)
1-7Reserved

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
0Output JPEG will be monochrome (otherwise it will be colour)
1-3Quality control:
ValueQuality
075% (the default level)
112%
225%
337%
450%
562%
675%
788%
4-7Reserved

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-15Reserved

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:

OffsetContents
R0Width in pixels of image
R1Height in pixels of image
R2Bits per pixel in the image
R3Image flags (see below)
R4X DPI
R5Y DPI

The image flags in R3 are:

Bit(s)Meaning
0Image has a palette (if <=8bpp)
1Image is colour (otherwise image is greyscale)
2Image has alpha channel or mask
3-5Interlace type:
ValueMeaning
0No interlacing
1Adam7 interlacing
2Vertical interlacing
3-7Reserved
6-31Reserved

This operation reads information about the image which is common to most bitmap-type operations.

SWI Calls

ImageFileConvert_ConvertSWI &56840
Convert an image from one format to another
R0=Flags for operation:
Bit(s)Meaning
0-7Reserved for options common to output filetype
8-15Reserved for options common to input filetype
16-23Reserved for options specific to the input/output pair
24-31Reserved
R1=Conversion requested:
Bit(s)Meaning
0-11Destination filetype
12-15Reserved, must be 0
16-25Source filetype
26-31Reserved, must be 0
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)
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to convert an image from one format to another.

ImageFileConvert_MiscOpSWI &56841
Miscellaneous operations on a conversion
R0=Flag bits:
Bit(s)Meaning
0-7Reserved for options common to output filetype
8-15Reserved for options common to input filetype
16-23Reserved for options specific to the input/output pair
24-31Reserved
R1=Conversion requested:
Bit(s)Meaning
0-11Destination filetype
12-15Reserved, must be 0
16-25Source filetype
26-31Reserved, must be 0
R2=Pointer to input image data
R3=Length of input image data
R4=Operation type:
RangeMeaning
&000-&3FFReserved for generic operations on all conversions
&400-&7FFReserved for operations specific to the output type
&800-&BFFReserved for operations specific to the input type
&C00-&FFFReserved for operations specific to the input/output pair
OtherReserved for future expansion
R5 - R9=Misc op parameters
R0 - R9=Updated by conversion module
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to provide miscellaneous operations to obtain information about the conversion process.

ImageFileConvert_RegisterSWI &56843
Register a new converter
R0=Flags (reserved, must be 0)
R1=Pointer to definition (all will be copied):
OffsetContents
0API version (100)
4Converter flags (bits 0-31 reserved, must be 0)
8Converter type:
Bit(s)Meaning
0-11Destination filetype
12-15Reserved, must be 0
16-25Source filetype
26-31Reserved, must be 0
12Pointer to name of converter in the form <name><tab><version x.xx><tab><author>
16Workspace value for R12
20Pointer to conversion routine
24Pointer to miscop routine
R1=API version (even if an error occurs)
R0,2 - R9=Preserved
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to register a new converter.

ImageFileConvert_DeregisterSWI &56844
Deregister a 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
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to deregister a converter.

ImageFileConvert_EnumerateConvertersSWI &56845
Enumerate the registered converters
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
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to enumerate the currently registered converters.

ImageFileConvert_ConverterInfoSWI &56842
Read information on a conversion
R0=Flags (reserved, must be 0)
R1=Filetype pair
R0=Pointer to renderer definition (read only)
R1=Pointer to renderer name
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

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.