bm_compress {bittermelon} | R Documentation |
Compress bitmaps by a factor of two by re-mapping to a “block elements” scheme.
bm_compress(bm_object, direction = "vertical")
bm_object |
Either a |
direction |
Either "vertical" or "v", "horizontal" or "h", OR "both" or "b". |
Depending on direction
we shrink the bitmaps height and/or width by
a factor of two and re-encode pairs/quartets of pixels to a “block elements” scheme.
If necessary we pad the right/bottom of the bitmap(s) by
a pixel. For each pair/quartet we determine the most-common non-zero element
and map them to a length twenty set of integers representing the “block
elements” scheme. For integers greater than zero we map it to higher twenty
character sets i.e. 1
's get mapped to 0:19, 2
's get mapped to 20:39, 3
's
get mapped to 40:59, etc. Using the default px_unicode
will give you the exact
matching “Block Elements” glyphs while px_ascii
gives the closest ASCII approximation.
Hence print.bm_bitmap()
should produce reasonable results for compressed bitmaps if
either of them are used as the px
argument.
Either a bm_bitmap()
, bm_list()
, or bm_font()
object.
See https://en.wikipedia.org/wiki/Block_Elements for more info on the Unicode Block Elements block.
font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
font <- read_hex(font_file)
r <- font[[str2ucp("R")]]
print(r, px = px_ascii)
print(bm_compress(r, "vertical"), px = px_ascii)
print(bm_compress(r, "horizontal"), px = px_ascii)
print(bm_compress(r, "both"), px = px_ascii)