Package dev.aherscu.qa.testing.utils
Class ImageUtils
- java.lang.Object
-
- dev.aherscu.qa.testing.utils.ImageUtils
-
public final class ImageUtils extends Object
Image manipulation utilities.- Author:
- Adrian Herscu
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImageUtils.Pipeline
Image transformation pipeline.
-
Field Summary
Fields Modifier and Type Field Description static Map<RenderingHints.Key,Object>
DEFAULT_RENDERING_HINTS
Rendering hints for best quality with scaling.static IndexColorModel
FOUR_BIT_COLOR_MODEL
Four-bit color model.static IndexColorModel
GREY_SCALE_COLOR_MODEL
Gray scale color model.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage>
adapt(org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage> pair)
Makes two images same size by scaling down the image with bigger area.static double
areaOf(BufferedImage image)
static BufferedImage
reduce(BufferedImage inputImage, IndexColorModel indexColorModel)
Reduces the color palette of specified image.static BufferedImage
scale(BufferedImage inputImage, double widthScale, double heightScale)
Scales a specified image using dedicated library.static BufferedImage
scale(BufferedImage inputImage, float widthScale, float heightScale, Map<RenderingHints.Key,Object> hints)
Scales a specified image using plain calls toGraphics2D
andAffineTransform
.
-
-
-
Field Detail
-
DEFAULT_RENDERING_HINTS
public static final Map<RenderingHints.Key,Object> DEFAULT_RENDERING_HINTS
Rendering hints for best quality with scaling.- See Also:
scale(BufferedImage, float, float, Map)
-
FOUR_BIT_COLOR_MODEL
public static final IndexColorModel FOUR_BIT_COLOR_MODEL
Four-bit color model.
-
GREY_SCALE_COLOR_MODEL
public static final IndexColorModel GREY_SCALE_COLOR_MODEL
Gray scale color model.
-
-
Method Detail
-
reduce
public static BufferedImage reduce(BufferedImage inputImage, IndexColorModel indexColorModel)
Reduces the color palette of specified image.- Parameters:
inputImage
- the image to reduceindexColorModel
- the color model to apply- Returns:
- the reduced image
-
scale
public static BufferedImage scale(BufferedImage inputImage, float widthScale, float heightScale, Map<RenderingHints.Key,Object> hints)
Scales a specified image using plain calls toGraphics2D
andAffineTransform
.Not best quality when scaling down.
- Parameters:
inputImage
- the image to scalewidthScale
- width scale factorheightScale
- height scale factorhints
- rendering hints- Returns:
- the scaled image
- See Also:
DEFAULT_RENDERING_HINTS
-
scale
public static BufferedImage scale(BufferedImage inputImage, double widthScale, double heightScale)
Scales a specified image using dedicated library.Good quality when scaling down.
- Parameters:
inputImage
- the image to scalewidthScale
- the width scale factorheightScale
- the height scale factor- Returns:
- the scaled image
-
areaOf
public static double areaOf(BufferedImage image)
- Parameters:
image
- the image- Returns:
- the area of image
-
adapt
public static org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage> adapt(org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage> pair)
Makes two images same size by scaling down the image with bigger area.- Parameters:
pair
- images to adapt- Returns:
- adapted images
-
-