QJCC homepage

biz.chitec.quarterback.swing
Class ImageMixer

java.lang.Object
  extended bybiz.chitec.quarterback.swing.ImageMixer
All Implemented Interfaces:
javax.swing.SwingConstants

public final class ImageMixer
extends java.lang.Object
implements javax.swing.SwingConstants

Helper class to create images and icons consisting of other images and icons.

Version:
$Id: 45c0f4982807cbecca5c611643a602fd8df1e2e5 $
Author:
cantamen/Dirk Hillbrecht 2004-2006 Distributed under the terms of the GNU LGPL.

Field Summary
private static byte[] emptypic
           
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
private ImageMixer()
          Uninstanciable as all methods are static.
 
Method Summary
static java.awt.image.BufferedImage combineBufferedImages(java.awt.image.BufferedImage[] images)
          Combine images in horizontal direction, vertically centered with no gap
static java.awt.image.BufferedImage combineBufferedImages(java.awt.image.BufferedImage[] images, int gap)
          Combine images in horizontal direction, vertically centered
static java.awt.image.BufferedImage combineBufferedImages(java.awt.image.BufferedImage[] images, int orientation, int alignment, int gap)
          Combine two or more BufferedImages into one.
static java.awt.Image getEmptyImage(int width, int height)
          Returns an empty, transparent image of the given size.
static byte[] getOnePixelTransparentPNGImageData()
          Returns a one-to-one-pixel transparent PNG file as byte array.
static java.awt.image.BufferedImage overlayBufferedImages(java.awt.image.BufferedImage[] images, int xalign, int yalign)
          Overlays two or more BufferedImages into one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

emptypic

private static final byte[] emptypic
Constructor Detail

ImageMixer

private ImageMixer()
Uninstanciable as all methods are static.

Method Detail

getOnePixelTransparentPNGImageData

public static byte[] getOnePixelTransparentPNGImageData()
Returns a one-to-one-pixel transparent PNG file as byte array.


getEmptyImage

public static java.awt.Image getEmptyImage(int width,
                                           int height)
Returns an empty, transparent image of the given size. This method is a little bit artefact-like, but it fits here best as we have static data for a transparent 1*1-picture available.

Parameters:
width - Width of the image to be created
height - Height of the empty image to be created
Returns:
A fresh Image object of the requested size

combineBufferedImages

public static java.awt.image.BufferedImage combineBufferedImages(java.awt.image.BufferedImage[] images,
                                                                 int orientation,
                                                                 int alignment,
                                                                 int gap)
Combine two or more BufferedImages into one. The source images are arranged into a single output image, either from left to right or from top to bottom. The returned image is always of INT_ARGB type. Pictures with indexed color model are converted internally into a flat version.

Parameters:
images - The input images.
orientation - HORIZONTAL or VERTICAL
alignment - TOP/CENTER/BOTTOM or LEFT/CENTER/RIGHT
gap - Gap between the pictures in pixel
Returns:
BufferedImage of TYPE_INT_ARGB containing the composition of BufferedImages

overlayBufferedImages

public static java.awt.image.BufferedImage overlayBufferedImages(java.awt.image.BufferedImage[] images,
                                                                 int xalign,
                                                                 int yalign)
Overlays two or more BufferedImages into one. The source images are arranged into a single output image, stacked one above the other. The first image comes bottommost, the last topmost. The resulting image is as large as the largest source images dictate (width and height handled seperately).

Parameters:
images - The input images.
xalign - LEFT/CENTER/RIGHT
yalign - TOP/CENTER/BOTTOM
Returns:
BufferedImage of TYPE_INT_ARGB containing the composition of input images

combineBufferedImages

public static java.awt.image.BufferedImage combineBufferedImages(java.awt.image.BufferedImage[] images,
                                                                 int gap)
Combine images in horizontal direction, vertically centered


combineBufferedImages

public static java.awt.image.BufferedImage combineBufferedImages(java.awt.image.BufferedImage[] images)
Combine images in horizontal direction, vertically centered with no gap


QJCC homepage