Name
SaveBrush -- save brush to a file (V2.0)
Synopsis
SaveBrush(id, f$[, t])
Deprecated syntax
SaveBrush(id, f$[, transcolor, fmt, table])
Function
This function saves the brush specified by id to the file specified by f$. By default, the brush will be saved as a Windows bitmap (BMP) file. This can be changed by passing a different format identifier to SaveBrush() (see below for details).

SaveBrush() supports several optional arguments. Before Hollywood 9.0, those had to be passed as optional parameters (see above). Since Hollywood 9.0, however, it is recommended to use the new syntax, which has a single optional table argument that can be used to pass one or more optional arguments to SaveBrush().

The following table fields are recognized by this function:

Format:
Set this tag to the image format that should be used. This can either be one of the following constants or an image saver provided by a plugin:

#IMGFMT_BMP:
Windows bitmap. Hollywood's BMP saver supports RGB and palette images. #IMGFMT_BMP is the default format used by SaveBrush().

#IMGFMT_PNG:
PNG format. Hollywood's PNG saver supports RGB and palette images. RGB images also can have an alpha channel, palette images can have a transparent pen. (V2.5)

#IMGFMT_JPEG:
JPEG format. Note that the JPEG format does not support alpha channels or palette-based graphics. The Quality field (see below) allows you to specify the quality level for the JPEG image (valid values are 0 to 100 where 100 is the best quality). (V4.0)

#IMGFMT_GIF:
GIF format. Because GIF images are always palette-based, RGB graphics have to be quantized before they can be exported as GIF. You can use the Colors and Dither tags (see below) to specify the number of palette entries to allocate for the image and whether or not dithering shall be applied. When using #IMGFMT_GIF with a palette brush, no quantizing will be done. #IMGFMT_GIF also supports palette images with a transparent pen. (V4.5)

#IMGFMT_ILBM:
IFF ILBM format. Hollywood's IFF ILBM saver supports RGB and palette images. Palette images can also have a transparent pen, alpha channels are unsupported for this output format. (V4.5)

Defaults to #IMGFMT_BMP.

Dither:
Set to True to enable dithering. This field is only handled when the destination format is palette-based and the source data is in RGB format. Defaults to False which means no dithering.

Depth:
Specifies the desired image depth. This is only handled when the format is palette-based and the source data is in RGB format. Valid values are between 1 (= 2 colors) and 8 (= 256 colors). Defaults to 8. (V9.0)

Colors:
This is an alternative to the Depth tag. Instead of a bit depth, you can pass how many colors the image shall use here. Again, this is only handled when the format is palette-based and the source data is in RGB format. Valid values are between 1 and 256. Defaults to 256.

Quality:
Here you can specify a value between 0 and 100 indicating the compression quality for lossy compression formats. A value of 100 means best quality, 0 means worst quality. This is only available for image formats that support lossy compression. Defaults to 90 which means pretty good quality.

FillColor:
When saving an RGB image that has transparent pixels, you can specify an RGB color that should be written to all transparent pixels here. This is probably of not much practical use. Defaults to #NOCOLOR which means that transparent pixels will be left as they are. (V9.0)

Adapter:
This tag allows you to specify one or more file adapters that should be asked if they want to save the specified file. If you use this tag, you must set it to a string containing the name(s) of one or more adapter(s). Defaults to the adapter set using SetDefaultAdapter(). See Loaders and adapters for details. (V10.0)

UserTags:
This tag can be used to specify additional data that should be passed to loaders and adapters. If you use this tag, you must set it to a table of key-value pairs that contain the additional data that should be passed to plugins. See User tags for details. (V10.0)

Here is an overview that shows which formats support which tags:

Inputs
id
identifier of the brush to save
f$
destination file
t
optional: table specifying further options (see above) (V9.0)
Example
SaveBrush(1, "test.jpg", {Format = #IMGFMT_JPEG, Quality = 80})
The code above saves brush 1 as "test.jpg" using a quality of 80%.

Show TOC