Class ImageUtilities


  • public class ImageUtilities
    extends Object
    An utility class image handling.
    Since:
    0.7.9
    Author:
    Andrea Antonello (www.hydrologis.com)
    • Constructor Detail

      • ImageUtilities

        public ImageUtilities()
    • 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
      • 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 null if 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:
        true if the image is all of the same color.