Class BitmapImageRenderer

java.lang.Object
org.apache.poi.sl.draw.BitmapImageRenderer
All Implemented Interfaces:
ImageRenderer

public class BitmapImageRenderer extends Object implements ImageRenderer
For now this class renders only images supported by the javax.imageio.ImageIO framework.
  • Constructor Details

    • BitmapImageRenderer

      public BitmapImageRenderer()
  • Method Details

    • canRender

      public boolean canRender(String contentType)
      Description copied from interface: ImageRenderer
      Determines if this image renderer implementation supports the given contentType
      Specified by:
      canRender in interface ImageRenderer
      Parameters:
      contentType - the image content type
      Returns:
      if the content type is supported
    • loadImage

      public void loadImage(InputStream data, String contentType) throws IOException
      Description copied from interface: ImageRenderer
      Load and buffer the image
      Specified by:
      loadImage in interface ImageRenderer
      Parameters:
      data - the raw image stream
      contentType - the content type
      Throws:
      IOException
    • loadImage

      public void loadImage(byte[] data, String contentType) throws IOException
      Description copied from interface: ImageRenderer
      Load and buffer the image
      Specified by:
      loadImage in interface ImageRenderer
      Parameters:
      data - the raw image bytes
      contentType - the content type
      Throws:
      IOException
    • getImage

      public BufferedImage getImage()
      Specified by:
      getImage in interface ImageRenderer
      Returns:
      the image as buffered image or null if image could not be loaded
    • getImage

      public BufferedImage getImage(Dimension2D dim)
      Specified by:
      getImage in interface ImageRenderer
      Parameters:
      dim - the dimension in pixels of the returned image
      Returns:
      the image as buffered image or null if image could not be loaded
    • getBounds

      public Rectangle2D getBounds()
      Specified by:
      getBounds in interface ImageRenderer
      Returns:
      the bounds of the buffered image in pixel
    • setAlpha

      public void setAlpha(double alpha)
      Specified by:
      setAlpha in interface ImageRenderer
      Parameters:
      alpha - the alpha [0..1] to be added to the image (possibly already containing an alpha channel)
    • setAlpha

      public static BufferedImage setAlpha(BufferedImage image, double alpha)
    • drawImage

      public boolean drawImage(Graphics2D graphics, Rectangle2D anchor)
      Description copied from interface: ImageRenderer
      Render picture data into the supplied graphics
      Specified by:
      drawImage in interface ImageRenderer
      Returns:
      true if the picture data was successfully rendered
    • drawImage

      public boolean drawImage(Graphics2D graphics, Rectangle2D anchor, Insets clip)
      Description copied from interface: ImageRenderer
      Render picture data into the supplied graphics
      Specified by:
      drawImage in interface ImageRenderer
      Returns:
      true if the picture data was successfully rendered
    • getNativeBounds

      public Rectangle2D getNativeBounds()
      Specified by:
      getNativeBounds in interface ImageRenderer
      Returns:
      the format-specific / not-normalized bounds of the image
    • setCacheInput

      public void setCacheInput(boolean enable)
      Description copied from interface: ImageRenderer
      Dis-/Enables caching of input data for later retrieval. Opposed to ImageRenderer.getImage(), which returns a BufferedImage, the cached image can be later used to embedded the original, unmodified data
      Specified by:
      setCacheInput in interface ImageRenderer
      Parameters:
      enable - dis-/enables caching - this is an optional operation. false removes already cached data
    • getCachedImage

      public byte[] getCachedImage()
      Specified by:
      getCachedImage in interface ImageRenderer
      Returns:
      the cached image data
    • getCachedContentType

      public String getCachedContentType()
      Specified by:
      getCachedContentType in interface ImageRenderer
      Returns:
      the cached content type