Learn R Programming

bittermelon (version 2.2.1)

bm_extract: Extract part of a bitmap

Description

bm_extract() can be used to extract part of a bitmap. For bm_bitmap() and bm_pixmap() objects it is a wrapper around [[()] with drop = FALSE for convenience in pipes.

Usage

bm_extract(x, ...)

# S3 method for bm_matrix bm_extract(x, rows = seq_len(nrow(x)), cols = seq_len(ncol(x)), ...)

# S3 method for bm_list bm_extract(x, ...)

# S3 method for `magick-image` bm_extract(x, rows = seq_len(bm_heights(x)), cols = seq_len(bm_widths(x)), ...)

# S3 method for nativeRaster bm_extract(x, rows = seq_len(nrow(x)), cols = seq_len(ncol(x)), ...)

# S3 method for raster bm_extract(x, rows = seq_len(nrow(x)), cols = seq_len(ncol(x)), ...)

Arguments

x

Either a bm_bitmap(), bm_font(), bm_list(), "magick-image", "nativeRaster", bm_pixmap(), or "raster" object.

...

Additional arguments to be passed to or from methods.

rows, cols

Integer vectors of rows and columns to extract. Rows are indexed from the bottom of the image.

See Also

[[.bm_matrix()], bm_trim()

Examples

Run this code
corn <- farming_crops_16x16()$corn$portrait
corn_top <- bm_extract(corn, rows = 9:16)
all.equal(corn_top, corn[9:16, ])
if (cli::is_utf8_output() && cli::num_ansi_colors() >= 256L) {
  print(corn_top, bg = "cyan", compress = "v")
}

Run the code above in your browser using DataLab