Package limn.graphics
Class BitmapIcon
java.lang.Object
limn.graphics.BitmapIcon
- All Implemented Interfaces:
Icon
An
Icon backed by pre-rendered Images (typically PNGs). Covers
the raster cases that don't come from vectors:
mask(Image...): a monochrome or grayscale mask that is recolored with the theme (tintable()istrue). Pass more than one image to supply per-resolution variants (e.g.@1x,@2x);image(int, boolean)picks the smallest one that still covers the requested device size.themed(Image, Image): pre-colored light and dark variants, drawn as-is (tintable()isfalse);image(int, boolean)chooses by theme brightness.picture(Image): a single pre-colored image, drawn as-is.
Bitmaps do not resample as cleanly as vectors, so for crisp results supply a
variant at (or above) the size you draw at, or prefer SvgIcon.
-
Nested Class Summary
Nested classes/interfaces inherited from interface limn.graphics.Icon
Icon.Mirroring -
Method Summary
Modifier and TypeMethodDescriptionimage(int pixelSize, boolean dark) The bitmap best suited to apixelSize×pixelSizebox measured in device pixels, for the given theme brightness.static BitmapIconA monochrome/grayscale mask recolored with the theme.static BitmapIconA single, pre-colored image drawn without tinting.static BitmapIconPre-colored light/dark variants, chosen by the active theme's brightness.booleantintable()WhetherIcon.image(int, boolean)returns a single-color mask to be recolored with the theme (true: SVG, grayscale/mono PNG), or a finished picture to draw as-is (false: pre-colored light/dark variants).
-
Method Details
-
mask
A monochrome/grayscale mask recolored with the theme. Supply one image, or several at different resolutions (any order) to be chosen by size. -
picture
A single, pre-colored image drawn without tinting. -
themed
Pre-colored light/dark variants, chosen by the active theme's brightness. -
tintable
public boolean tintable()Description copied from interface:IconWhetherIcon.image(int, boolean)returns a single-color mask to be recolored with the theme (true: SVG, grayscale/mono PNG), or a finished picture to draw as-is (false: pre-colored light/dark variants). Governs whetherIcon.paint(limn.graphics.Canvas, float, float, float, limn.graphics.Color, boolean)applies its tint. -
image
Description copied from interface:IconThe bitmap best suited to apixelSize×pixelSizebox measured in device pixels, for the given theme brightness. Vector icons rasterize at exactly this size (so they stay sharp on HiDPI and at any zoom); bitmap icons pick their nearest available variant.Answers on the calling thread, and has no asynchronous form on purpose:
Icon.paint(limn.graphics.Canvas, float, float, float, limn.graphics.Color, boolean)calls it from inside a frame, and a paint that asked for a bitmap has to be given one before it can finish. An implementation whose bitmap is expensive to produce carries the warm-up on its own type instead, where the caller can run it ahead of the frame;SvgIcon.imageAsync(int)is the one that does.
-