fr.umlv.platform
Class Images

java.lang.Object
  extended by fr.umlv.platform.Images

public class Images
extends java.lang.Object

A helper class for loading and croping images.


Method Summary
Modifier and Type Method and Description
static java.awt.image.BufferedImage createCompatibleMirrorImage(java.awt.image.BufferedImage image)
          Create a new image that is the mirror along the right border of the image taken as argument;
static java.awt.image.BufferedImage createCompatibleSubImage(java.awt.image.BufferedImage image, int x, int y, int width, int height)
          Copied a chunk of an image into a new image created a format compatible with the default screen configuration.
static java.awt.image.BufferedImage loadImage(java.lang.Class<?> baseClass, java.lang.String filename)
          Loads an image from a file in a directory or in a jar.
static java.awt.image.BufferedImage loadImage(java.io.File file)
          Deprecated. you should use loadImage(Class, String) instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadImage

@Deprecated
public static java.awt.image.BufferedImage loadImage(java.io.File file)
                                              throws java.io.IOException
Deprecated. you should use loadImage(Class, String) instead.

Loads an image from a file. The decoder is chosen depending on the extension of the file (png, gif, etc). The hardware specific data structure of the returned image should be released using Image.flush() when the image is not needed anymore.

Parameters:
file - a file containing an image.
Returns:
an in-memory image
Throws:
java.io.IOException - if the file is not found or the field doesn't contain an image.

loadImage

public static java.awt.image.BufferedImage loadImage(java.lang.Class<?> baseClass,
                                                     java.lang.String filename)
                                              throws java.io.IOException
Loads an image from a file in a directory or in a jar. The image is found by appending to the package of the baseClass the filename. The decoder is chosen depending on the extension of the file (png, gif, etc). The hardware specific data structure of the returned image should be released using Image.flush() when the image is not needed anymore.

Parameters:
baseClass - class that will be used to find the package in which the image will be looked up.
filename - the name of the image file or a relative path to the image file.
Returns:
an in-memory image
Throws:
java.io.IOException - if the file is not found or the field doesn't contain an image.

createCompatibleSubImage

public static java.awt.image.BufferedImage createCompatibleSubImage(java.awt.image.BufferedImage image,
                                                                    int x,
                                                                    int y,
                                                                    int width,
                                                                    int height)
Copied a chunk of an image into a new image created a format compatible with the default screen configuration. The dimension of the newly created image is widthxheight.

Parameters:
image - the source image.
x - offset along x-axis in the source image.
y - offset along y-axis in the source image.
width - width of the destination image and of the zone of the source image that will be copied.
height - height of the destination image and of the zone of the source image that will be copied.
Returns:
a new in-memory image

createCompatibleMirrorImage

public static java.awt.image.BufferedImage createCompatibleMirrorImage(java.awt.image.BufferedImage image)
Create a new image that is the mirror along the right border of the image taken as argument;

Parameters:
image - the image to be mirrored.
Returns:
a new image compatible with the current configuration that will contains the mirror image.