[id] = RGBArrayToBrush(id, table, width, height[, transtype, invalpha])
table
. The table can be regarded as a matrix containing height
number of rows where each row has width
number of elements. The order
of the pixel data in this table must be as follows: Row after row in
top-down format, i.e. the table starts with the first row of pixels.
Every row must contain exactly width
number of pixels, and there must
be at least height
number of rows. The single pixels must be passed in
the RGB format with an optional alpha value. The transtype
argument
allows you to specify the transparency type the new brush should use.
This can be either #NONE
for no transparency, #MASK
for monochrome
transparency, and #ALPHACHANNEL
for alpha channel transparency.
The optional argument invalpha
can be used to tell RGBArrayToBrush()
that all alpha channel values are inverted. This means that a value of
0 means 100% visibility and a value of 255 means invisibility. Normally,
it is just the other way round. Due to historical reasons, the Hollywood
drawing library uses inverted alpha values, and this why they are also
supported by RGBArrayToBrush()
, although they are not the default.
If transtype
is set to #NONE
, the pixels' alpha values are ignored
altogether and invalpha
does not have any effect either.
Please note that the table that you pass to this function will usually eat lots of memory. Thus, you should set this table to Nil as soon as you no longer need it. Otherwise you will waste huge amounts of memory and it could even happen that your script runs out of memory altogether. So please keep in mind that you should always set pixel array tables to Nil as soon as you are done with them.
To convert a brush to a pixel array, you can use the BrushToRGBArray() function.
transtype
is set to #MASK
or
#ALPHACHANNEL
you must also specify alpha values in the
highest 8 bits#NONE
)False
which means do not invert alpha values)pixels = {} col = #BLUE stp = 256 / 480 For Local y = 0 To 479 For Local x = 0 To 639 Do pixels[y * 640 + x] = col col = col - stp Next RGBArrayToBrush(1, pixels, 640, 480) pixels = Nil ; IMPORTANT: free memory! DisplayBrush(1, 0, 0)The code above creates a color gradient from red to
#BLACK
and converts
it into a brush using RGBArrayToBrush()
. Important: Do not forget to set
the pixel array to Nil when you no longer need it because otherwise it
will stay in memory and pixel arrays will eat huge amounts of memory!