Name
hw_SaveImage -- save image (V9.0)
Synopsis
int ok = hw_SaveImage(STRPTR file, APTR data, int width, int height,
                  ULONG fmt, ULONG flags, struct hwTagList *tags);
Function
This function saves the raw pixel array specified in data to the file specified by filename. You also need to pass the image dimensions in pixels to hw_SaveImage(). The array passed in data can either be a 32-bit or an 8-bit pixel array. If it is an 8-bit pixel array, the pixels are interpreted as CLUT data so you also have to pass the color palette in the HWSVIMGTAG_PALETTE tag (see below).

The fmt argument must be set to an image format provided by a plugin or to one of the following inbuilt image savers:

HWIMGFMT_BMP:
Windows bitmap format. Supports RGB and CLUT image data. No support for alpha channels or transparent pens.

HWIMGFMT_PNG:
PNG image. Supports RGB and CLUT image data. Supports alpha channels and transparent pens.

HWIMGFMT_JPEG:
JPEG image. Only RGB data is supported. No support for alpha channels. Since JPEG is a lossy format, it supports a quality setting via the HWSVIMGTAG_QUALITY tag (see below).

HWIMGFMT_GIF:
GIF image. Only CLUT data is supported. Transparent pens are supported.

HWIMGFMT_ILBM:
IFF ILBM image. Supports RGB and CLUT data. Transparent pens are supported but not alpha channels.

Furthermore, hw_SaveImage() accepts a tag list which can be used to configure the following options:

HWSVIMGTAG_QUALITY:
For lossy compression formats like HWIMGFMT_JPEG, you can use this tag to set the desired compression level (an integer between 0 and 100). By default, a quality of 90 is used.

HWSVIMGTAG_DEPTH:
Set this to the depth of the pixel data passed in the data parameter. This can be 24 for RGB data without alpha channel, 32 for RGB data with alpha channel and 8 for CLUT data. Note that even if you set this tag to 24, the pixel data must still be passed as 32-bit ULONG pixels. Defaults to 32.

HWSVIMGTAG_PALETTE:
If you pass CLUT data to hw_SaveImage(), you need to set this tag to a palette containing the pen colors. The palette must be passed as an array of 256 ULONG. Note that even if the image uses less than 256 colors, you still need to set HWSVIMGTAG_DEPTH to 8 and the array you pass here still needs to contain 256 entries.

HWSVIMGTAG_TRANSPEN:
If you pass CLUT data to hw_SaveImage(), you can set this tag to a pen that should be made transparent. Defaults to HWPEN_NONE which means no pen shall be transparent.

Designer compatibility
Unsupported

Inputs
file
output file name
data
raw pixel data, either as 32-bit or 8-bit pixels
width
width of the image in pixels
height
height of the image in pixels
fmt
output format identifier (see above)
flags
reserved for future use, pass 0 for now
tags
tag list containing additional options (see above)
Results
ok
True or False to indicate success or failure

Show TOC