Class ImageHelper


  • public class ImageHelper
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageHelper()  
    • Method Summary

      Modifier and Type Method Description
      static java.awt.image.BufferedImage cloneImage​(java.awt.image.BufferedImage bi)
      Clones an image.
      static java.awt.image.BufferedImage convertImage2Binary​(java.awt.image.BufferedImage image)
      Deprecated.
      As of release 1.1, renamed to convertImageToBinary(BufferedImage image)
      static java.awt.image.BufferedImage convertImageToBinary​(java.awt.image.BufferedImage image)
      A simple method to convert an image to binary or B/W image.
      static java.awt.image.BufferedImage convertImageToGrayscale​(java.awt.image.BufferedImage image)
      A simple method to convert an image to gray scale.
      static java.awt.Image getClipboardImage()
      Gets an image from Clipboard.
      static java.awt.image.BufferedImage getScaledInstance​(java.awt.image.BufferedImage image, int targetWidth, int targetHeight)
      Convenience method that returns a scaled instance of the provided BufferedImage.
      static javax.imageio.IIOImage getScaledInstance​(javax.imageio.IIOImage iioSource, float scale)
      Convenience method that returns a scaled instance of the provided IIOImage.
      static java.awt.image.BufferedImage getSubImage​(java.awt.image.BufferedImage image, int x, int y, int width, int height)
      A replacement for the standard BufferedImage.getSubimage method.
      static java.awt.image.BufferedImage invertImageColor​(java.awt.image.BufferedImage image)
      Inverts image color.
      static java.awt.image.BufferedImage rotateImage​(java.awt.image.BufferedImage image, double angle)
      Rotates an image.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ImageHelper

        public ImageHelper()
    • Method Detail

      • getScaledInstance

        public static java.awt.image.BufferedImage getScaledInstance​(java.awt.image.BufferedImage image,
                                                                     int targetWidth,
                                                                     int targetHeight)
        Convenience method that returns a scaled instance of the provided BufferedImage.
        Parameters:
        image - the original image to be scaled
        targetWidth - the desired width of the scaled instance, in pixels
        targetHeight - the desired height of the scaled instance, in pixels
        Returns:
        a scaled version of the original BufferedImage
      • getScaledInstance

        public static javax.imageio.IIOImage getScaledInstance​(javax.imageio.IIOImage iioSource,
                                                               float scale)
        Convenience method that returns a scaled instance of the provided IIOImage.
        Parameters:
        iioSource - the original image to be scaled
        scale - the desired scale
        Returns:
        a scaled version of the original IIOImage
      • getSubImage

        public static java.awt.image.BufferedImage getSubImage​(java.awt.image.BufferedImage image,
                                                               int x,
                                                               int y,
                                                               int width,
                                                               int height)
        A replacement for the standard BufferedImage.getSubimage method.
        Parameters:
        image -
        x - the X coordinate of the upper-left corner of the specified rectangular region
        y - the Y coordinate of the upper-left corner of the specified rectangular region
        width - the width of the specified rectangular region
        height - the height of the specified rectangular region
        Returns:
        a BufferedImage that is the subimage of image.
      • convertImageToBinary

        public static java.awt.image.BufferedImage convertImageToBinary​(java.awt.image.BufferedImage image)
        A simple method to convert an image to binary or B/W image.
        Parameters:
        image - input image
        Returns:
        a monochrome image
      • convertImage2Binary

        @Deprecated
        public static java.awt.image.BufferedImage convertImage2Binary​(java.awt.image.BufferedImage image)
        Deprecated.
        As of release 1.1, renamed to convertImageToBinary(BufferedImage image)
        A simple method to convert an image to binary or B/W image.
        Parameters:
        image - input image
        Returns:
        a monochrome image
      • convertImageToGrayscale

        public static java.awt.image.BufferedImage convertImageToGrayscale​(java.awt.image.BufferedImage image)
        A simple method to convert an image to gray scale.
        Parameters:
        image - input image
        Returns:
        a monochrome image
      • invertImageColor

        public static java.awt.image.BufferedImage invertImageColor​(java.awt.image.BufferedImage image)
        Inverts image color.
        Parameters:
        image - input image
        Returns:
        an inverted-color image
      • rotateImage

        public static java.awt.image.BufferedImage rotateImage​(java.awt.image.BufferedImage image,
                                                               double angle)
        Rotates an image.
        Parameters:
        image - the original image
        angle - the degree of rotation
        Returns:
        a rotated image
      • getClipboardImage

        public static java.awt.Image getClipboardImage()
        Gets an image from Clipboard.
        Returns:
        image
      • cloneImage

        public static java.awt.image.BufferedImage cloneImage​(java.awt.image.BufferedImage bi)
        Clones an image. http://stackoverflow.com/questions/3514158/how-do-you-clone-a-bufferedimage
        Parameters:
        bi -
        Returns: