Name
SaveImage -- save image to disk (V5.0)
Synopsis
int ok = SaveImage(STRPTR filename, struct SaveImageCtrl *ctrl);
Function
This function must save the image provided by the pointer in the second parameter to the filename specified in the first parameter. Hollywood passes a pointer to a struct SaveImageCtrl to this function. This structure looks like this:

 
struct SaveImageCtrl
{
    APTR Data;                      // [in]
    ULONG *Palette;                 // [in]
    int Width;                      // [in]
    int Height;                     // [in]
    int Modulo;                     // [in]
    int Format;                     // [in]
    int Quality;                    // [in]
    int Colors;                     // [in]
    ULONG TransIndex;               // [in]
    ULONG Flags;                    // [in]
    ULONG FormatID;                 // [in] -- V5.3
    STRPTR Adapter;                 // [in] -- V10.0
    struct hwUserTagList *UserTags; // [in] -- V10.0
};

In this structure Hollywood passes the following information to your SaveImage() function:

Data:
The pixel data to save to the file. The actual format of this data depends on the Format member.

Width:
Width of the image in pixels.

Height:
Height of the image in pixels.

Modulo:
Number of bytes used by a single row of pixel data. This may be larger than the specified width because there may be some padding involved.

Format:
This specifies the pixel format of the source data passed in Data. May be one of the following constants:

HWSAVEIMGFMT_ARGB:
Data is a 32-bit array consisting of ARGB pixels.

HWSAVEIMGFMT_CLUT:
Data contains 8-bit indices into a color look-up table. This color look-up table is passed in Palette below.

You will only have to handle those formats here that you have explicitly declared as supported when Hollywood called your RegisterImageSaver() function.

Quality:
This contains a value between 0 and 100 indicating the desired quality for the output file. Image formats that use lossy compression can use this member to determine compression settings for the image. Image formats that don't use any compression or offer lossless compression can ignore this member.

Colors:
This contains the number of colors in the color look-up table passed in the Palette member. This member is only used if Format is HWSAVEIMGFMT_CLUT.

Palette:
Contains the look-up table that you need to convert the CLUT pixel values to RGB color values. This table consists of as many 32-bit ARGB values as has been set in the Colors member. Note that Palette is only used if Format is HWSAVEIMGFMT_CLUT.

TransIndex:
If Format is HWSAVEIMGFMT_CLUT this member specifies the index of the color that should appear transparent in the image. The value specified here is only valid if the HWSAVEIMGFLAGS_TRANSINDEX flag has been set (see below).

Flags:
Contains a combination of flags specifying further options:

HWSAVEIMGFLAGS_ALPHA:
Pixel data contains alpha channel transparency values.

HWSAVEIMGFLAGS_TRANSINDEX:
The TransIndex member contains the index of a palette entry that should be made transparent in the output image.

FormatID:
This member contains the identifier of the image format the file should be saved in. You only need to look at this member if your plugin supports more than one output image format. But be careful, you are only allowed to look at this member if the user is running at least Hollywood 5.3. Otherwise, you must not access this member because older versions of Hollywood don't support it. (V5.3)

Adapter:
Starting with Hollywood 10.0 users can specify the file adapter that should be used to save an image file. If this member is non-NULL, Hollywood wants your plugin to use the file adapter specified in Adapter to save the image. This means that you have to use hw_FOpenExt() instead of hw_FOpen() to save the image. Make sure to check for Hollywood 10.0 before trying to access this member because it isn't there in previous versions. See hw_FOpenExt for details. (V10.0)

UserTags:
This member will be set to a list of user tags in case they were specified in the Hollywood script. User tags are a way of passing additional information from Hollywood scripts to plugin functions. Note that even if your plugin doesn't support any user tags, you should still look for this tag and pass the user tags to hw_FOpenExt because the user tags passed in UserTags could also be intended for another plugin, namely the file adapter plugin passed in Adapter. See User tags for details. Make sure to check for Hollywood 10.0 before trying to access this member because it isn't there in previous versions. (V10.0)

This function has to return True if the image has been successfully saved or False in case of an error.

Inputs
filename
path to a destination file
ctrl
pointer to a struct SaveImageCtrl containing the image to be saved
Results
ok
True or False indicating success or failure

Show TOC