BrushToPenArray -- convert palette brush to pen array (V9.0)
table = BrushToPenArray(id)
This command copies all pens from the specified palette 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.

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

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 pen array back to a palette brush, you can use the PenArrayToBrush() function. See PenArrayToBrush for details.

If you want to have RGB colors instead of pen values, you have to use the BrushToRGBArray() function instead. See BrushToRGBArray for details.

identifier of the palette brush to be converted to a pen array
a table containing all pens from the source brush; do not forget to set this table to Nil when you are done with it!

Show TOC