at.tuwien.ifs.somtoolbox.util
Class ImageUtils

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.util.ImageUtils

public class ImageUtils
extends Object

This class provides methods to manipulate images.

Version:
$Id: ImageUtils.java 3608 2010-06-25 08:46:18Z mayer $
Author:
Rudolf Mayer

Nested Class Summary
(package private) static class ImageUtils.Origin
           
 
Constructor Summary
ImageUtils()
           
 
Method Summary
static BufferedImage autoCrop(BufferedImage bi)
          Automatically crops an image, by continously removing full rows or columns from all sides, as long as all the pixels in them are all white
static BufferedImage createEmptyImage(int width, int height)
          Creates a BufferedImage with a white, empty background.
static BufferedImage createImage(int width, int height, int bkcolor)
          Creates a BufferedImage with the given colour as background
static boolean equalPixelContent(BufferedImage i1, BufferedImage i2)
          Compares if two images contain the same pixel content
private static int findNumberOfColumnsToCrop(BufferedImage bi, ImageUtils.Origin origin)
          Computes how many cols of pixels can be cropped from the specified ImageUtils.Origin; only ImageUtils.Origin.LEFT and ImageUtils.Origin.RIGHT are valid
private static int findNumberOfRowsToCrop(BufferedImage bi, ImageUtils.Origin origin)
          Computes how many rows of pixels can be cropped from the specified ImageUtils.Origin; only ImageUtils.Origin.TOP and ImageUtils.Origin.BOTTOM are valid
static BufferedImage scaleImage(BufferedImage buim, int width)
           
static BufferedImage scaleImageByHeight(BufferedImage buim, int height)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUtils

public ImageUtils()
Method Detail

autoCrop

public static BufferedImage autoCrop(BufferedImage bi)
Automatically crops an image, by continously removing full rows or columns from all sides, as long as all the pixels in them are all white


findNumberOfRowsToCrop

private static int findNumberOfRowsToCrop(BufferedImage bi,
                                          ImageUtils.Origin origin)
Computes how many rows of pixels can be cropped from the specified ImageUtils.Origin; only ImageUtils.Origin.TOP and ImageUtils.Origin.BOTTOM are valid


findNumberOfColumnsToCrop

private static int findNumberOfColumnsToCrop(BufferedImage bi,
                                             ImageUtils.Origin origin)
Computes how many cols of pixels can be cropped from the specified ImageUtils.Origin; only ImageUtils.Origin.LEFT and ImageUtils.Origin.RIGHT are valid


equalPixelContent

public static boolean equalPixelContent(BufferedImage i1,
                                        BufferedImage i2)
Compares if two images contain the same pixel content


scaleImage

public static BufferedImage scaleImage(BufferedImage buim,
                                       int width)

scaleImageByHeight

public static BufferedImage scaleImageByHeight(BufferedImage buim,
                                               int height)

createEmptyImage

public static BufferedImage createEmptyImage(int width,
                                             int height)
Creates a BufferedImage with a white, empty background.


createImage

public static BufferedImage createImage(int width,
                                        int height,
                                        int bkcolor)
Creates a BufferedImage with the given colour as background