as.array.bm_bitmap() / as.array.bm_pixmap() casts bm_bitmap() / bm_pixmap() objects to an array of numeric values representing the RGBA channels.
These arrays can be used in functions such as png::writePNG().
Arguments
- x
Either a
bm_bitmap()orbm_pixmap()object.- ...
Currently ignored.
- first_row_is_top
If
TRUEthe first row of the matrix will represent the top of the bitmap (likegrDevices::as.raster()objects). IfFALSEthe first row of the matrix will represent the bottom of the bitmap (likebm_bitmap()andbm_pixmap()objects).- col
Character vector of R color specifications. First color is used for values equal to 0, second color for values equal to 1, etc.
Examples
corn <- farming_crops_16x16()$corn$portrait
a <- as.array(corn)
f <- tempfile(fileext = ".png")
png::writePNG(a, f)