Class ArtImages

java.lang.Object
com.codename1.art.ArtImages

public final class ArtImages extends Object
Encodes rasters as PNG and decodes PNG, JPEG and other image bytes into rasters.
  • Field Details

    • MAX_DIMENSION

      public static final int MAX_DIMENSION
      The largest width or height a decoded image may have.
      See Also:
    • MAX_SVG_SIDE

      public static final int MAX_SVG_SIDE
      The largest side, in pixels, renderSvg renders. A larger document fails rather than allocate hundreds of megabytes on a device; render it with ArtRenderer.toImage at a scale of your choosing instead.
      See Also:
  • Method Details

    • renderSvg

      public static Image renderSvg(byte[] svg) throws IOException

      Renders an SVG document, once, into an ordinary image at the size it declares. This is what Image.createSVG answers on a platform without native SVG.

      Parameters
      • svg: the document
      Returns

      the rendered image

      Throws
      • IOException: if the data is not SVG or is larger than MAX_SVG_SIDE on a side
      Throws:
      IOException
    • decode

      public static Raster decode(byte[] data)

      Decodes image bytes. PNG is decoded in pure Java; other formats go through the platform and need an initialized display.

      Parameters
      • data: the encoded image
      Returns

      the pixels, or null when the bytes are not an image this platform can decode

    • encodePng

      public static byte[] encodePng(Raster r)

      Encodes pixels as a 32-bit RGBA PNG.

      Parameters
      • r: the pixels