hw_SaveImage -- save image (V9.0)
int ok = hw_SaveImage(STRPTR file, APTR data, int width, int height,
                  ULONG fmt, ULONG flags, struct hwTagList *tags);
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:

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

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

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).

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

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:

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.

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.

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.

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

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

Show TOC