| bm_distort | R Documentation |
bm_distort() resize bitmaps to arbitrary width and height value via magick::image_resize().
bm_downscale() is a wrapper to bm_distort() that downscales an image if (and only if) it is
wider than a target width.
bm_distort(x, width = NULL, height = NULL, ...)
bm_downscale(x, width = getOption("width"), ...)
## S3 method for class 'bm_bitmap'
bm_distort(
x,
width = NULL,
height = NULL,
...,
filter = "Point",
threshold = 0.5
)
## S3 method for class 'bm_list'
bm_distort(x, ...)
## S3 method for class 'bm_pixmap'
bm_distort(x, width = NULL, height = NULL, ..., filter = "Point")
## S3 method for class ''magick-image''
bm_distort(x, width = NULL, height = NULL, ..., filter = "Point")
## S3 method for class 'nativeRaster'
bm_distort(x, width = NULL, height = NULL, ..., filter = "Point")
## S3 method for class 'raster'
bm_distort(x, width = NULL, height = NULL, ..., filter = "Point")
x |
Either a |
width |
Desired width of bitmap |
height |
Desired height of bitmap |
... |
Additional arguments to be passed to or from methods. |
filter |
Passed to |
threshold |
When the alpha channel weakly exceeds this threshold (on an interval from zero to one) then the pixel is determined to be “black”. |
Depending on x either a bm_bitmap(), bm_font(), bm_list(), magick-image, "nativeRaster", bm_pixmap(), or raster object.
bm_expand() for expanding width/height by integer multiples.
bm_resize() for resizing an image via trimming/extending an image.
font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
font <- read_hex(font_file)
capital_r <- font[[str2ucp("R")]]
dim(capital_r) # 8 x 16
if (requireNamespace("magick", quietly = TRUE)) {
capital_r_9x21 <- bm_distort(capital_r, width = 9L, height = 21L)
print(capital_r_9x21)
}
crops <- farming_crops_16x16()
corn <- crops$corn$portrait
dim(corn) # 16 x 16
if (cli::is_utf8_output() &&
cli::num_ansi_colors() >= 256L &&
requireNamespace("magick", quietly = TRUE)) {
corn_24x24 <- bm_distort(corn, width = 24L)
print(corn_24x24, compress = "v")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.