public class Scaling extends Object
ScalingIterator.
| Constructor and Description |
|---|
Scaling()
|
| Modifier and Type | Method and Description |
|---|---|
static void |
scale(BufferedImage
Scales the source image into the destination.
|
static BufferedImage |
scale(BufferedImage
Scales the source image into the dest.
|
static BufferedImage |
scale(BufferedImage
Scales the source image to a new, smaller size.
|
static BufferedImage |
scale(BufferedImage
Scales the source image to a new, smaller size.
|
static BufferedImage |
scale(File
Scales the source image file to a new, smaller size.
|
static BufferedImage |
scale(Image
Scales the source image into the dest.
|
static BufferedImage |
scale(URL
Scales the source image file to a new size.
|
static Dimension2D |
scaleDimensionsProportionally(Dimension2D
This is a convenience method to calculate how to scale down an image proportionally.
|
static Dimension |
scaleDimensionsProportionally(Dimension
This is a convenience method to calculate how to scale down an image proportionally.
|
static BufferedImage |
scaleProportionally(BufferedImage
Scales the source image proportionally to a new, smaller size.
|
static BufferedImage |
scaleProportionally(BufferedImage
Scales the source image proportionally to a new, smaller size.
|
public static void scale(BufferedImagesource, BufferedImage dest)
source - the source image.
dest - the destination image. This must be smaller than the source image or an exception will be thrown. Also this need to be of type
BufferedImage.TYPE_INT_ARGB.
public static BufferedImagescale(BufferedImage source, int w, int h)
source - the source image.
w - the new width. This must be less than the width of the source image, or an exception will be thrown.
h - the new height. This must be less than the height of the source image, or an exception will be thrown.
BufferedImage.TYPE_INT_ARGB.
public static BufferedImagescale(BufferedImage source, Dimension destSize)
source - the source image.
destSize - the size of the new image. This must be smaller than the size of the source image, or an exception will be thrown.
BufferedImage.TYPE_INT_ARGB or
BufferedImage.TYPE_INT_RGB.
public static BufferedImagescale(File source, int preferredType, Dimension destSize)
source - the source image file.
preferredType -
TYPE_INT_RGB,
TYPE_INT_ARGB,
TYPE_3BYTE_BGR,
TYPE_4BYTE_ABGR.
destSize - the size of the new image.
BufferedImage.TYPE_INT_ARGB or
BufferedImage.TYPE_INT_RGB.
public static BufferedImagescale(URL source, int preferredType, Dimension destSize)
source - the source image file.
preferredType -
TYPE_INT_RGB,
TYPE_INT_ARGB,
TYPE_3BYTE_BGR,
TYPE_4BYTE_ABGR.
destSize - the size of the new image.
BufferedImage.TYPE_INT_ARGB or
BufferedImage.TYPE_INT_RGB.
public static BufferedImagescale(BufferedImage source, BufferedImage dest, Dimension destSize)
source - the source image. This may not be null.
dest - the destination image. If non-null: this image must be at least
destSize pixels in size or an exception will be thrown. If this is null: an image will be created that is
destSize pixels.
This argument can be the same as the source argument. This may save some memory allocation, but it will permanently alter the source image.
Also this need to be of type BufferedImage.TYPE_INT_ARGB.
destSize - the dimensions to write to. It is guaranteed that these pixels will be replaced in the dest image.
dest argument, or a new image if no
dest argument was provided.
public static BufferedImagescale(Image source, BufferedImage dest, Dimension destSize)
source - the source image. This may not be null.
dest - the destination image. If non-null: this image must be at least
destSize pixels in size or an exception will be thrown. If this is null: an image will be created that is
destSize pixels.
This argument can be the same as the source argument. This may save some memory allocation, but it will permanently alter the source image.
Also this need to be of type BufferedImage.TYPE_INT_ARGB.
destSize - the dimensions to write to. It is guaranteed that these pixels will be replaced in the dest image. If this is null then the image will not be scaled.
dest argument, or a new image if no
dest argument was provided.
public static BufferedImagescaleProportionally(BufferedImage image, int maxWidth, int maxHeight)
The new image will either have a width of maxWidth or a height of maxHeight (or both).
image - the source image to scale.
maxWidth - the maximum width the scaled image can be.
maxHeight - the maximum height the scaled image can be.
public static BufferedImagescaleProportionally(BufferedImage image, Dimension maxSize)
The new image will either have a height of maxWidth or a height of maxHeight (or both).
image - the source image to scale.
maxSize - the maximum dimensions the scaled image can be.
public static DimensionscaleDimensionsProportionally(Dimension originalSize, Dimension maxSize)
originalSize - the original image dimensions.
maxSize - the maximum new dimensions.
maxSize or smaller.
public static Dimension2DscaleDimensionsProportionally(Dimension2D originalSize, Dimension2D maxSize)
originalSize - the original image dimensions.
maxSize - the maximum new dimensions.
maxSize or smaller.