BrushToRGBArray -- convert brush to pixel array (V5.0)
table = BrushToRGBArray(id[, invalpha])
This command copies all pixels from the specified brush to a table and returns that table to you. The table can be seen as a matrix containing a number of rows that is identical to the brush's height where each row has a number of elements that is identical to the brush's width. 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.

Note that the rows won't be stored as subtables. The table returned by BrushToRGBArray() will be one-dimensional and will contain exactly $height * $width elements, stored sequentially, row after row.

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.

Note that for palette brushes, there is also the BrushToPenArray() function which will return the brush's pen values instead of RGB colors. See BrushToPenArray for details.

identifier of the brush to convert to RGB array
optional: whether to use inverted alpha values (defaults to False which means do not invert alpha values)
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