Package org.apache.poi.sl.draw
Class BitmapImageRenderer
- java.lang.Object
-
- org.apache.poi.sl.draw.BitmapImageRenderer
-
- All Implemented Interfaces:
ImageRenderer
public class BitmapImageRenderer extends java.lang.Object implements ImageRenderer
For now this class renders only images supported by the javax.imageio.ImageIO framework.
-
-
Constructor Summary
Constructors Constructor Description BitmapImageRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRender(java.lang.String contentType)
Determines if this image renderer implementation supports the given contentTypeboolean
drawImage(java.awt.Graphics2D graphics, java.awt.geom.Rectangle2D anchor)
Render picture data into the supplied graphicsboolean
drawImage(java.awt.Graphics2D graphics, java.awt.geom.Rectangle2D anchor, java.awt.Insets clip)
Render picture data into the supplied graphicsjava.awt.geom.Rectangle2D
getBounds()
java.lang.String
getCachedContentType()
byte[]
getCachedImage()
java.awt.image.BufferedImage
getImage()
java.awt.image.BufferedImage
getImage(java.awt.geom.Dimension2D dim)
java.awt.geom.Rectangle2D
getNativeBounds()
void
loadImage(byte[] data, java.lang.String contentType)
Load and buffer the imagevoid
loadImage(java.io.InputStream data, java.lang.String contentType)
Load and buffer the imagevoid
setAlpha(double alpha)
static java.awt.image.BufferedImage
setAlpha(java.awt.image.BufferedImage image, double alpha)
void
setCacheInput(boolean enable)
Dis-/Enables caching of input data for later retrieval.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.poi.sl.draw.ImageRenderer
getDimension, getGenericRecord, setDefaultCharset
-
-
-
-
Method Detail
-
canRender
public boolean canRender(java.lang.String contentType)
Description copied from interface:ImageRenderer
Determines if this image renderer implementation supports the given contentType- Specified by:
canRender
in interfaceImageRenderer
- Parameters:
contentType
- the image content type- Returns:
- if the content type is supported
-
loadImage
public void loadImage(java.io.InputStream data, java.lang.String contentType) throws java.io.IOException
Description copied from interface:ImageRenderer
Load and buffer the image- Specified by:
loadImage
in interfaceImageRenderer
- Parameters:
data
- the raw image streamcontentType
- the content type- Throws:
java.io.IOException
-
loadImage
public void loadImage(byte[] data, java.lang.String contentType) throws java.io.IOException
Description copied from interface:ImageRenderer
Load and buffer the image- Specified by:
loadImage
in interfaceImageRenderer
- Parameters:
data
- the raw image bytescontentType
- the content type- Throws:
java.io.IOException
-
getImage
public java.awt.image.BufferedImage getImage()
- Specified by:
getImage
in interfaceImageRenderer
- Returns:
- the image as buffered image or null if image could not be loaded
-
getImage
public java.awt.image.BufferedImage getImage(java.awt.geom.Dimension2D dim)
- Specified by:
getImage
in interfaceImageRenderer
- 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 java.awt.geom.Rectangle2D getBounds()
- Specified by:
getBounds
in interfaceImageRenderer
- Returns:
- the bounds of the buffered image in pixel
-
setAlpha
public void setAlpha(double alpha)
- Specified by:
setAlpha
in interfaceImageRenderer
- Parameters:
alpha
- the alpha [0..1] to be added to the image (possibly already containing an alpha channel)
-
setAlpha
public static java.awt.image.BufferedImage setAlpha(java.awt.image.BufferedImage image, double alpha)
-
drawImage
public boolean drawImage(java.awt.Graphics2D graphics, java.awt.geom.Rectangle2D anchor)
Description copied from interface:ImageRenderer
Render picture data into the supplied graphics- Specified by:
drawImage
in interfaceImageRenderer
- Returns:
- true if the picture data was successfully rendered
-
drawImage
public boolean drawImage(java.awt.Graphics2D graphics, java.awt.geom.Rectangle2D anchor, java.awt.Insets clip)
Description copied from interface:ImageRenderer
Render picture data into the supplied graphics- Specified by:
drawImage
in interfaceImageRenderer
- Returns:
- true if the picture data was successfully rendered
-
getNativeBounds
public java.awt.geom.Rectangle2D getNativeBounds()
- Specified by:
getNativeBounds
in interfaceImageRenderer
- 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 toImageRenderer.getImage()
, which returns aBufferedImage
, the cached image can be later used to embedded the original, unmodified data- Specified by:
setCacheInput
in interfaceImageRenderer
- Parameters:
enable
- dis-/enables caching - this is an optional operation.false
removes already cached data
-
getCachedImage
public byte[] getCachedImage()
- Specified by:
getCachedImage
in interfaceImageRenderer
- Returns:
- the cached image data
-
getCachedContentType
public java.lang.String getCachedContentType()
- Specified by:
getCachedContentType
in interfaceImageRenderer
- Returns:
- the cached content type
-
-