Package net.sourceforge.plantuml.swing
Class ImageHelper
java.lang.Object
net.sourceforge.plantuml.swing.ImageHelper
A collection of methods to help with processing images. A majority of this
code was originally found online.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Dimension
getScaledDimension
(Dimension dim, double zoom) static Dimension
getScaledDimension
(Dimension imgSize, 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 Dimension
getScaledDimensionWidthFit
(Dimension imgSize, Dimension boundary) static BufferedImage
getScaledInstance
(BufferedImage img, Dimension targetDim, RenderingHints hints, boolean higherQuality) Returns a scaled instance of aBufferedImage
.static BufferedImage
toBufferedImage
(Image img) Converts an Image to a BufferedImage.
-
Constructor Details
-
ImageHelper
public ImageHelper()
-
-
Method Details
-
getScaledInstance
public static BufferedImage getScaledInstance(BufferedImage img, Dimension targetDim, RenderingHints hints, boolean higherQuality) Returns a scaled instance of aBufferedImage
. Modified from: https://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html- Parameters:
img
- 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 theBILINEAR
hint is specified)- Returns:
- a scaled version of the original
BufferedImage
-
toBufferedImage
Converts an Image to a BufferedImage. From: http://stackoverflow.com/questions/13605248/java-converting-image-to-bufferedimage -
getScaledDimension
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. From: http://stackoverflow.com/questions/10245220/java-image-resize-maintain-aspect-ratio- Parameters:
imgSize
- dimensions of the original image.boundary
- dimensions of the area the image is to be drawn in.
-
getScaledDimensionWidthFit
-
getScaledDimension
-