public class ImageUtil
extends java.lang.Object
Constructor and Description |
---|
ImageUtil() |
Modifier and Type | Method and Description |
---|---|
static java.awt.image.BufferedImage |
createCompatibleImage(int width,
int height,
boolean supportTransparency)
Returns a
BufferedImage that supports the specified
transparency and has a data layout and color model
compatible with this GraphicsConfiguration . |
static java.awt.image.BufferedImage |
getAlphaImage(java.awt.image.BufferedImage image) |
static boolean |
hasAlpha(java.awt.Image image)
This method returns
true if the specified image has the
possibility to store transparent pixels. |
static java.awt.image.BufferedImage |
toBufferedImage(java.awt.Image image)
This method returns a buffered image with the contents of an image.
|
static java.awt.image.BufferedImage |
toBufferedImage(java.awt.Image image,
boolean forceCopy)
This method returns a buffered image with the contents of an image.
|
static java.awt.image.BufferedImage |
toBufferedImage(java.awt.image.RenderedImage image)
Converts an arbitrary image to a
BufferedImage . |
static boolean |
usesAlpha(java.awt.Image image)
This method returns
true if the specified image has at least one
pixel that is not fully opaque. |
public static java.awt.image.BufferedImage createCompatibleImage(int width, int height, boolean supportTransparency)
BufferedImage
that supports the specified
transparency and has a data layout and color model
compatible with this GraphicsConfiguration
.
The returned BufferedImage
has a layout and
color model that can be optimally blitted to a device
with this GraphicsConfiguration
.public static java.awt.image.BufferedImage getAlphaImage(java.awt.image.BufferedImage image)
public static boolean hasAlpha(java.awt.Image image)
true
if the specified image has the
possibility to store transparent pixels.
Inspired by http://www.exampledepot.com/egs/java.awt.image/HasAlpha.htmlimage
- Image that should be checked for alpha channel.true
if the specified image can have transparent pixels,
false
otherwisepublic static java.awt.image.BufferedImage toBufferedImage(java.awt.Image image)
image
- Image to be convertedpublic static java.awt.image.BufferedImage toBufferedImage(java.awt.Image image, boolean forceCopy)
image
- Image to be convertedforceCopy
- This parameter has no effect unless the source image is a BufferedImage.
If false the source image will be returned as-is, since it is already a BufferedImage.
If true, a new BufferedImage (which is compatible with the screen) will be created
even if the source image is already a buffered image.public static java.awt.image.BufferedImage toBufferedImage(java.awt.image.RenderedImage image)
BufferedImage
.image
- Image that should be converted.BufferedImage
.public static boolean usesAlpha(java.awt.Image image)
true
if the specified image has at least one
pixel that is not fully opaque.image
- Image that should be checked for non-opaque pixels.true
if the specified image has transparent pixels,
false
otherwise