Name
BrushToRGBArray -- convert brush to pixel array (V5.0)
Synopsis
table = BrushToRGBArray(id[, invalpha])
Function
This command stores all pixels of the specified brush inside a table and returns this table to you. The table can be regarded as a matrix containing 'brush-height' number of rows where each row has 'brush-width' number of elements. The order of the pixel data in this table is as follows: Row after row in top-down format, i.e. the table starts with the first row of pixels. The single pixels are stored as ARGB values.

The optional argument invalpha can be used to tell BrushToRGBArray() that all alpha channel values shall be 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 BrushToRGBArray(), although they are not the default.

Please note that the table that you get from 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 pixel array back to a brush, you can use the RGBArrayToBrush() function.

Inputs
id
identifier of the brush to convert to RGB array
invalpha
optional: whether to use inverted alpha values (defaults to False which means do not invert alpha values)
Results
table
a table containing all pixels from the source brush; do not forget to set this table to Nil when you are done with it!

Show TOC