com.gif4j
Class ImageUtils

java.lang.Object
  extended bycom.gif4j.ImageUtils

public class ImageUtils
extends java.lang.Object

This class containts some useful image processing methods.

Version:
1.0
Author:
Gif4J Software - Java GIF image processing solutions

Constructor Summary
ImageUtils()
           
 
Method Summary
static java.awt.image.BufferedImage addInsets(java.awt.image.BufferedImage image, java.awt.Insets insets, java.awt.Paint paint)
          Add the specified insets to the specified image and fill span between image and new borders with the specified Paint.
static java.awt.image.BufferedImage borderWithPaint(java.awt.image.BufferedImage image, int width, int height, java.awt.Paint paint)
          Put the specified image into the center of rectangle (with the specified width and height) and fill span between image and rectangle's borders with the specified Paint.
static java.awt.image.BufferedImage scale(java.awt.image.BufferedImage source, int newWidth, int newHeight, boolean keepRatio)
          Convenient static method to resize down (minimize) instance of BufferedImage to the specified size.
static java.awt.image.BufferedImage toBufferedImage(java.awt.Image image)
          Convenient static method to convert Image instances to BufferedImage instances.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUtils

public ImageUtils()
Method Detail

addInsets

public static final java.awt.image.BufferedImage addInsets(java.awt.image.BufferedImage image,
                                                           java.awt.Insets insets,
                                                           java.awt.Paint paint)
Add the specified insets to the specified image and fill span between image and new borders with the specified Paint.

Parameters:
image - image to inset
insets - instance of Insets class
paint - to fill the span
Returns:
BufferedImage instance with added insets.
Throws:
java.lang.NullPointerException - If image is null
See Also:
Insets, Paint

borderWithPaint

public static java.awt.image.BufferedImage borderWithPaint(java.awt.image.BufferedImage image,
                                                           int width,
                                                           int height,
                                                           java.awt.Paint paint)
Put the specified image into the center of rectangle (with the specified width and height) and fill span between image and rectangle's borders with the specified Paint. If image's size greater than the specified then the image is returned without processing.

Parameters:
image - image to border
width - rectangle width to put image into
height - rectangle height to put image into
paint - paint to fill the span
Returns:
BufferedImage instance. If image's size greater than the specified then the image is returned without processing.
Throws:
java.lang.NullPointerException - If image is null
See Also:
Paint

scale

public static final java.awt.image.BufferedImage scale(java.awt.image.BufferedImage source,
                                                       int newWidth,
                                                       int newHeight,
                                                       boolean keepRatio)
Convenient static method to resize down (minimize) instance of BufferedImage to the specified size. If source image size less then the specified then the method returns the source image without processing. If 'keepRatio' parameter is true then the specified image will resize proportionally and new size can be not exactly equal to the specified newWidth/newHeight.

Parameters:
source - image to resize down (minimize)
newWidth - width which source image should be minimized to (the result image can have less width if 'keepRatio' parameter set to true)
newHeight - height which source image should be minimized to (the result image can have less height if 'keepRatio' parameter set to true)
keepRatio - resize image proportionally
Returns:
new minimized instance of BufferedImage or source image if its' width and height less than the specified newWidth and newHeight
Throws:
java.lang.NullPointerException - If source image is null
See Also:
BufferedImage

toBufferedImage

public static final java.awt.image.BufferedImage toBufferedImage(java.awt.Image image)
Convenient static method to convert Image instances to BufferedImage instances. If the specified image is already instance of BufferedImage then it's returned without processing.

Parameters:
image - image to convert if it's necessary
Returns:
instance of BufferedImage or null if Image loading process is failed
Throws:
java.lang.NullPointerException - image is null
See Also:
Image, BufferedImage