int error = hw_AddBrush(lua_State *L, lua_ID *id, int width, int height, struct hwAddBrush *ctrl);
lua_ID
. See Object identifiers for details. Additionally, you have to specify
the brush's width and height as well as a pointer to a struct hwAddBrush
which contains further information. struct hwAddBrush
looks like this:
struct hwAddBrush { ULONG *Data; int LineWidth; ULONG Transparency; ULONG Flags; APTR Image; ULONG *(*GetImage)(APTR handle, struct LoadImageCtrl *ctrl); void (*FreeImage)(APTR handle); int (*TransformImage)(APTR handle, struct hwMatrix2D *m, int width, int height); int Depth; // V9.0 ULONG *Palette; // V9.0 }; |
You need to provide the following information in this structure:
Data:
HWABFLAGS_VECTORBRUSH
flag is not set. The format of Data
depends on whether you want hw_AddBrush()
to create
a palette brush or an RGB brush. For RGB brushes, set this structure member to a pointer to an
array of 32-bit ARGB pixels that contain the image data for the new brush. hw_AddBrush()
will only take the alpha byte into account if the HWABFLAGS_USEALPHA
flag has been set.
Otherwise the alpha byte is ignored. For palette brushes, you must provide an 8-bit array
of pixels. Note that 8-bit pixels must be used even if the palette depth is less than 8
bits. The pixel array specified here must contain exactly as many pixels per row as passed
in the LineWidth
member. If you set Data
to NULL
and HWABFLAGS_VECTORBRUSH
isn't set,
hw_AddBrush()
will create an uninitialized raster brush for you, i.e. it will be filled with
random pixel data.
LineWidth:
Data
is not NULL
. In that
case, you have to set this structure member to the number of pixels per row in the Data
pixel array. This can be different from the value passed in the width
parameter of
hw_AddBrush()
in case the pixel array you specified in Data
contains some padding bytes.
Please note that LineWidth
must be specified in pixels, not in bytes.
Transparency:
HWABFLAGS_USETRANSPARENCY
flag has been set, this member contains a 24-bit RGB
color that should be made transparent. Hollywood will scan through the pixel array
passed in Data
and create a monochrome mask for the new brush in which all pixels which
match the RGB color specified here are transparent. This member is only supported for raster
brushes. Note that for palette brushes, i.e. if the HWABFLAGS_USEPALETTE
flag is set,
Transparency
needs to specify a pen that should be made transparent instead. For no
transparent pen, set this to HWPEN_NONE
.
Depth:
HWABFLAGS_USEPALETTE
is set, this member must be set to the palette depth. This
must be between 1 and 8. When creating RGB brushes, this member needn't be set. (V9.0)
Palette:
HWABFLAGS_USEPALETTE
is set, this member must be set to a ULONG
array containing
the palette colors, specified as raw RGB values. Note that the array you pass here must
contain 256 entries, even if the palette depth is less than 8. (V9.0)
Flags:
HWABFLAGS_USEALPHA:
Data
has to contain transparency information in the alpha byte. If a vector brush
is created, your GetImage()
implementation must return transparency information in the
alpha byte as well. If this flag is not set, hw_AddBrush()
will ignore whatever is in
the alpha byte. This flag and HWABFLAGS_USETRANSPARENCY
are mutually exclusive.
HWABFLAGS_USETRANSPARENCY:
Data
. In that case, setting this flag indicates that you want hw_AddBrush()
to create
a mask in which all pixels that match the color specified in Transparency
are made transparent.
That is why you also need to set the Transparency
member if you set this flag. This flag
and HWABFLAGS_USEALPHA
are mutually exclusive.
HWABFLAGS_VECTORBRUSH:
hw_AddBrush()
will create a vector brush for you. Vector brushes
can be transformed without any quality loss and whenever the script wants to have a vector
brush scaled, rotated, or transformed, Hollywood will call into your plugin to apply this
transformation to your vector brush. That is why you need to provide several callbacks
when creating a vector brush (see below).
HWABFLAGS_USEPALETTE:
Palette
and Depth
members (see above). (V9.0)
Image:
GetImage:
FreeImage:
TransformImage:
You can free brushes by calling the hw_FreeBrush() function.
lua_State
struct hwAddBrush
containing additional information