org.jtheque.utils.ui
Class ImageUtils

java.lang.Object
  extended by org.jtheque.utils.ui.ImageUtils

public final class ImageUtils
extends Object

Utility class for image processing.

Author:
Baptiste Wicht

Method Summary
static BufferedImage createCompatibleImage(BufferedImage image)
          Create a compatible image from an existing image.
static Image createCompatibleImage(int width, int height)
          Create a compatible image.In headless mode, this method will return a simple BufferedImage of type ARGB.
static BufferedImage createCompatibleImage(int width, int height, int type)
          Create a compatible image.
static BufferedImage createReflection(BufferedImage image)
          Create a reflection of the image.
static BufferedImage createThumbnail(BufferedImage image, int requestedThumbSize)
          Create a thumbnail of an image.
static boolean isHeadless()
          Indicate if we are in a headless mode or normal.
static BufferedImage openCompatibleImage(InputStream stream)
          Open a compatible image form an input stream.
static BufferedImage openCompatibleImageFromClassPath(String path)
          Open a image from the classpath at the specified path.
static BufferedImage openCompatibleImageFromFileSystem(String path)
          Open an image from the file system at the specified path.
static BufferedImage read(File file)
          Read an image from a file.
static BufferedImage read(InputStream stream)
          Open an image from an input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createThumbnail

public static BufferedImage createThumbnail(BufferedImage image,
                                            int requestedThumbSize)
Create a thumbnail of an image.

Parameters:
image - The source image.
requestedThumbSize - The requested size.
Returns:
The thumbnail

read

public static BufferedImage read(File file)
Read an image from a file.

Parameters:
file - The file to read from.
Returns:
The buffered image from the file.

read

public static BufferedImage read(InputStream stream)
Open an image from an input stream.

Parameters:
stream - The stream to read from.
Returns:
The buffered image from the stream.

createCompatibleImage

public static Image createCompatibleImage(int width,
                                          int height)
Create a compatible image.In headless mode, this method will return a simple BufferedImage of type ARGB.

Parameters:
width - The width.
height - The height.
Returns:
A compatible image.
See Also:
isHeadless()

createCompatibleImage

public static BufferedImage createCompatibleImage(int width,
                                                  int height,
                                                  int type)
Create a compatible image. In headless mode, this method will return a simple BufferedImage.

Parameters:
width - The width.
height - The height.
type - The type of the image.
Returns:
A compatible image.
See Also:
isHeadless()

createCompatibleImage

public static BufferedImage createCompatibleImage(BufferedImage image)
Create a compatible image from an existing image. In headless mode, this method will not affect the image.

Parameters:
image - The image to make compatible.
Returns:
A compatible image filled with the base image.

isHeadless

public static boolean isHeadless()
Indicate if we are in a headless mode or normal.

Returns:
true if we are in headless mode else false.

createReflection

public static BufferedImage createReflection(BufferedImage image)
Create a reflection of the image.

Parameters:
image - The image to reflect.
Returns:
The reflection image.

openCompatibleImageFromClassPath

public static BufferedImage openCompatibleImageFromClassPath(String path)
Open a image from the classpath at the specified path.

Parameters:
path - The path to the image.
Returns:
The image.

openCompatibleImageFromFileSystem

public static BufferedImage openCompatibleImageFromFileSystem(String path)
Open an image from the file system at the specified path.

Parameters:
path - The path to the image.
Returns:
The image or null if the file doesn't exist.

openCompatibleImage

public static BufferedImage openCompatibleImage(InputStream stream)
Open a compatible image form an input stream.

Parameters:
stream - The stream to use to open the image.
Returns:
The image.


Copyright © 2010 JTheque. All Rights Reserved.