public class ImageHelper
extends java.lang.Object
Constructor and Description |
---|
ImageHelper() |
Modifier and Type | Method and Description |
---|---|
static java.awt.Dimension |
getScaledDimension(java.awt.Dimension imgSize,
java.awt.Dimension boundary)
Calculates the dimensions of a scaled image given the dimensions of an image
and the area it is to be drawn in while preserving aspect ratio.
|
static java.awt.Dimension |
getScaledDimension(java.awt.Dimension dim,
double zoom) |
static java.awt.Dimension |
getScaledDimensionWidthFit(java.awt.Dimension imgSize,
java.awt.Dimension boundary) |
static java.awt.image.BufferedImage |
getScaledInstance(java.awt.image.BufferedImage img,
java.awt.Dimension targetDim,
java.awt.RenderingHints hints,
boolean higherQuality)
Returns a scaled instance of a
BufferedImage . |
static java.awt.image.BufferedImage |
toBufferedImage(java.awt.Image img)
Converts an Image to a BufferedImage.
|
public static java.awt.image.BufferedImage getScaledInstance(java.awt.image.BufferedImage img, java.awt.Dimension targetDim, java.awt.RenderingHints hints, boolean higherQuality)
BufferedImage
.
Modified from:
https://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.htmlimg
- the original image to be scaledtargetDim
- the desired dimensions of the scaled instance, in pixelshints
- RenderingHints used when scaling the imagehigherQuality
- if true, this method will use a multi-step scaling
technique that provides higher quality than the usual
one-step technique (only useful in downscaling cases,
targetDim is smaller than the original dimensions, and
generally only when the BILINEAR
hint is
specified)BufferedImage
public static java.awt.image.BufferedImage toBufferedImage(java.awt.Image img)
public static java.awt.Dimension getScaledDimension(java.awt.Dimension imgSize, java.awt.Dimension boundary)
imgSize
- dimensions of the original image.boundary
- dimensions of the area the image is to be drawn in.public static java.awt.Dimension getScaledDimensionWidthFit(java.awt.Dimension imgSize, java.awt.Dimension boundary)
public static java.awt.Dimension getScaledDimension(java.awt.Dimension dim, double zoom)