Groovy Documentation

com.blogofbug.utility
[Java] Class ImageUtilities

java.lang.Object
  com.blogofbug.utility.ImageUtilities

public class ImageUtilities
extends Object

Static class with utility methods for images

Authors:
nigel


Constructor Summary
ImageUtilities()

 
Method Summary
static BufferedImage copyImage(BufferedImage image)

Produces a copy of the supplied image

static BufferedImage createCompatibleImage(int width, int height)

Creates an image compatible with the current display

static BufferedImage loadCompatibleImage(String imageURL)

Loads an image in a format compatible with the current display

static BufferedImage renderComponentToImage(JComponent component)

Renders a component into an image, which is useful for playing with the component's resultant image in special effects or transitions

static BufferedImage renderTextToImage(Font font, Color textColor, String text, int width)

Renders a paragraph of text (line breaks ignored) to an image (created and returned).

static BufferedImage renderTextToImage(Font font, Color textColor, String[] text, int width)

Renders multiple paragraphs of text in an array to an image (created and returned).

static BufferedImage scaledImage(BufferedImage image, int width, int height)

Produces a resized image that is of the given dimensions

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Constructor Detail

ImageUtilities

ImageUtilities()


 
Method Detail

copyImage

public static BufferedImage copyImage(BufferedImage image)
Produces a copy of the supplied image
Parameters:
image - The original image
Returns:
The new BufferedImage


createCompatibleImage

public static BufferedImage createCompatibleImage(int width, int height)
Creates an image compatible with the current display
Returns:
A BufferedImage with the appropriate color model


loadCompatibleImage

public static BufferedImage loadCompatibleImage(String imageURL)
Loads an image in a format compatible with the current display
Returns:
A BufferedImage with the appropriate color model


renderComponentToImage

public static BufferedImage renderComponentToImage(JComponent component)
Renders a component into an image, which is useful for playing with the component's resultant image in special effects or transitions
Parameters:
component - The component to render
Returns:
A buffered image with the rendered component.


renderTextToImage

public static BufferedImage renderTextToImage(Font font, Color textColor, String text, int width)
Renders a paragraph of text (line breaks ignored) to an image (created and returned).
Parameters:
font - The font to use
textColor - The color of the text
text - The message
width - The width the text should be limited to
Returns:
An image with the text rendered into it


renderTextToImage

public static BufferedImage renderTextToImage(Font font, Color textColor, String[] text, int width)
Renders multiple paragraphs of text in an array to an image (created and returned).
Parameters:
font - The font to use
textColor - The color of the text
text - The message in an array of strings (one paragraph in each
width - The width the text should be limited to
Returns:
An image with the text rendered into it


scaledImage

public static BufferedImage scaledImage(BufferedImage image, int width, int height)
Produces a resized image that is of the given dimensions
Parameters:
image - The original image
width - The desired width
height - The desired height
Returns:
The new BufferedImage


 

Groovy Documentation