Package limn.graphics

Class BitmapIcon

java.lang.Object
limn.graphics.BitmapIcon
All Implemented Interfaces:
Icon

public final class BitmapIcon extends Object implements Icon
An Icon backed by pre-rendered Images (typically PNGs). Covers the raster cases that don't come from vectors:

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 Type
    Method
    Description
    image(int pixelSize, boolean dark)
    The bitmap best suited to a pixelSize×pixelSize box measured in device pixels, for the given theme brightness.
    static BitmapIcon
    mask(Image... resolutions)
    A monochrome/grayscale mask recolored with the theme.
    static BitmapIcon
    picture(Image image)
    A single, pre-colored image drawn without tinting.
    static BitmapIcon
    themed(Image light, Image dark)
    Pre-colored light/dark variants, chosen by the active theme's brightness.
    boolean
    Whether Icon.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).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface limn.graphics.Icon

    paint, paint
  • Method Details

    • mask

      public static BitmapIcon mask(Image... resolutions)
      A monochrome/grayscale mask recolored with the theme. Supply one image, or several at different resolutions (any order) to be chosen by size.
    • picture

      public static BitmapIcon picture(Image image)
      A single, pre-colored image drawn without tinting.
    • themed

      public static BitmapIcon themed(Image light, Image dark)
      Pre-colored light/dark variants, chosen by the active theme's brightness.
    • tintable

      public boolean tintable()
      Description copied from interface: Icon
      Whether Icon.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 whether Icon.paint(limn.graphics.Canvas, float, float, float, limn.graphics.Color, boolean) applies its tint.
      Specified by:
      tintable in interface Icon
    • image

      public Image image(int pixelSize, boolean dark)
      Description copied from interface: Icon
      The bitmap best suited to a pixelSize×pixelSize box 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.

      Specified by:
      image in interface Icon
      Parameters:
      pixelSize - target extent in physical pixels (≥ 1)
      dark - whether the active theme is dark (selects light/dark variants)