Class ImageUtilities
- java.lang.Object
-
- org.hortonmachine.gears.utils.images.ImageUtilities
-
public class ImageUtilities extends Object
An utility class image handling.- Since:
- 0.7.9
- Author:
- Andrea Antonello (www.hydrologis.com)
-
-
Constructor Summary
Constructors Constructor Description ImageUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanareEqual(BufferedImage img1, BufferedImage img2)static BufferedImageimageFromReader(org.geotools.coverage.grid.io.AbstractGridCoverage2DReader reader, int cols, int rows, double w, double e, double s, double n, org.opengis.referencing.crs.CoordinateReferenceSystem resampleCrs)Read an image from a coverage reader.static booleanisAllOneColor(BufferedImage image)Checks if an image is all of one color.static BufferedImagemakeColorTransparent(BufferedImage bufferedImageToProcess, Color colorToMakeTransparent)Make a color of the image transparent.static BufferedImagerendereImage2BufferedImage(RenderedImage renderedImage)static BufferedImagerotateImageByDegrees(BufferedImage img, double angle)static BufferedImagescaleImage(BufferedImage image, int newSize)Scale an image to a given size maintaining the ratio.
-
-
-
Method Detail
-
scaleImage
public static BufferedImage scaleImage(BufferedImage image, int newSize) throws Exception
Scale an image to a given size maintaining the ratio.- Parameters:
image- the image to scale.newSize- the size of the new image (it will be used for the longer side).- Returns:
- the scaled image.
- Throws:
Exception
-
rotateImageByDegrees
public static BufferedImage rotateImageByDegrees(BufferedImage img, double angle)
-
imageFromReader
public static BufferedImage imageFromReader(org.geotools.coverage.grid.io.AbstractGridCoverage2DReader reader, int cols, int rows, double w, double e, double s, double n, org.opengis.referencing.crs.CoordinateReferenceSystem resampleCrs) throws IOException
Read an image from a coverage reader.- Parameters:
reader- the reader.cols- the expected cols.rows- the expected rows.w- west bound.e- east bound.s- south bound.n- north bound.- Returns:
- the image or
nullif unable to read it. - Throws:
IOException
-
makeColorTransparent
public static BufferedImage makeColorTransparent(BufferedImage bufferedImageToProcess, Color colorToMakeTransparent)
Make a color of the image transparent.- Parameters:
bufferedImageToProcess- the image to extract the color from.colorToMakeTransparent- the color to make transparent.- Returns:
- the new image.
-
isAllOneColor
public static boolean isAllOneColor(BufferedImage image)
Checks if an image is all of one color.- Parameters:
image- the image to check.- Returns:
trueif the image is all of the same color.
-
areEqual
public static boolean areEqual(BufferedImage img1, BufferedImage img2)
-
rendereImage2BufferedImage
public static BufferedImage rendereImage2BufferedImage(RenderedImage renderedImage)
-
-