public class ImageUtil
extends java.lang.Object
| Constructor and Description |
|---|
ImageUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
clearImage(java.awt.image.BufferedImage image)
Sets the background of the image to white.
|
static void |
clearImage(java.awt.image.BufferedImage image,
java.awt.Color bgColor)
Sets the background of the image to the specified color
|
static java.awt.image.BufferedImage |
convertToBufferedImage(java.awt.Image awtImg,
int type)
Utility method to convert an AWT Image to a BufferedImage.
|
static java.awt.image.BufferedImage |
createCompatibleBufferedImage(int width,
int height)
Creates a BufferedImage compatible with the local graphics environment; this is a helper method for a
common process and just sets up and calls
GraphicsConfiguration.createCompatibleImage(int,int,int). |
static java.awt.image.BufferedImage |
createCompatibleBufferedImage(int width,
int height,
int biType)
Helper method to instantiate new BufferedImages; if the graphics environment is actually connected to real
screen devices (e.g.
|
static java.awt.image.BufferedImage |
createTransparentImage(int width,
int height) |
static byte[] |
getEmbeddedBase64Image(java.lang.String imageDataUri)
Get the binary content of an embedded base 64 image.
|
static java.awt.image.BufferedImage |
getScaledInstance(java.awt.image.BufferedImage orgImage,
int targetWidth,
int targetHeight)
Scales an image to the requested width and height, assuming these are both >= 1; size given in pixels.
|
static java.awt.image.BufferedImage |
getScaledInstance(ScalingOptions opt,
java.awt.image.BufferedImage orgImage)
Scales an image to the requested width and height, assuming these are both >= 1; size given in pixels.
|
static boolean |
isEmbeddedBase64Image(java.lang.String uri)
Detect if an URI represents an embedded base 64 image.
|
static java.awt.image.BufferedImage |
loadEmbeddedBase64Image(java.lang.String imageDataUri)
Get the BufferedImage of an embedded base 64 image.
|
static java.awt.image.BufferedImage |
makeCompatible(java.awt.image.BufferedImage bimg) |
static java.util.List |
scaleMultiple(ScalingOptions opt,
java.awt.image.BufferedImage img,
java.util.List dimensions)
Scales one image to multiple dimensions, using the same ScalingOptions for each.
|
public static void clearImage(java.awt.image.BufferedImage image,
java.awt.Color bgColor)
image - the imagebgColor - the colorpublic static void clearImage(java.awt.image.BufferedImage image)
image - the imagepublic static java.awt.image.BufferedImage makeCompatible(java.awt.image.BufferedImage bimg)
public static java.awt.image.BufferedImage createCompatibleBufferedImage(int width,
int height,
int biType)
GraphicsConfiguration.createCompatibleImage(int,int,int). The image will not have anything
drawn to it, not even a white background; you must do this yourself. The #clearBackground(BufferedImage)
method will do this for you if you like.width - Target width for the imageheight - Target height for the imagebiType - Value from the BufferedImage class; see docs for
BufferedImage.BufferedImage(int,int,int). The actual type used will
be the type specified in this parameter, if in headless mode, or the type most compatible with the screen, if
in non-headless more.public static java.awt.image.BufferedImage createCompatibleBufferedImage(int width,
int height)
GraphicsConfiguration.createCompatibleImage(int,int,int). The image will support
transparent pixels.width - Target width for the imageheight - Target height for the imagepublic static java.awt.image.BufferedImage getScaledInstance(ScalingOptions opt, java.awt.image.BufferedImage orgImage)
Image.getScaledInstance(int,int,int) is considered to perform poorly compared to more
recent developed techniques.
For a discussion of the options from a member of the Java2D team, see
http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.htmlorgImage - The image to scalepublic static java.awt.image.BufferedImage getScaledInstance(java.awt.image.BufferedImage orgImage,
int targetWidth,
int targetHeight)
Image.getScaledInstance(int,int,int) is considered to perform poorly compared to more
recent developed techniques.
For a discussion of the options from a member of the Java2D team, see
http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.htmlorgImage - The image to scaletargetWidth - The target width in pixelstargetHeight - The target height in pixelspublic static java.util.List scaleMultiple(ScalingOptions opt, java.awt.image.BufferedImage img, java.util.List dimensions)
#getScaledInstance(ScalingOptions,java.awt.Image).opt - Options to apply to control scaling process.img - The original image to scaledimensions - List of dimensions to scale to; one output image will be produced for each dimension. Will
not check for duplicate dimensions.public static java.awt.image.BufferedImage convertToBufferedImage(java.awt.Image awtImg,
int type)
awtImg - image to convert; if already a BufferedImage, returned unmodifiedtype - the type of BufferedImage to create; see
BufferedImage.BufferedImage(int,int,int)public static java.awt.image.BufferedImage createTransparentImage(int width,
int height)
public static boolean isEmbeddedBase64Image(java.lang.String uri)
uri - URI of the imagepublic static byte[] getEmbeddedBase64Image(java.lang.String imageDataUri)
imageDataUri - URI of the embedded imagepublic static java.awt.image.BufferedImage loadEmbeddedBase64Image(java.lang.String imageDataUri)
imageDataUri - URI of the embedded imageCopyright © 2014. All Rights Reserved.