com.jhlabs.image
Class ImageUtils
java.lang.Object
com.jhlabs.image.ImageUtils
public abstract class ImageUtils
extends java.lang.Object
A class containing some static utility methods for dealing with BufferedImages.
static BufferedImage | cloneImage(BufferedImage image) - Clones a BufferedImage.
|
static void | composeThroughMask(Raster src, WritableRaster dst, Raster sel) - Compose src onto dst using the alpha of sel to interpolate between the two.
|
static BufferedImage | convertImageToARGB(Image image) - Convert an Image into a TYPE_INT_ARGB BufferedImage.
|
static BufferedImage | createImage(ImageProducer producer) - Cretae a BufferedImage from an ImageProducer.
|
static int[] | getRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) - A convenience method for getting ARGB pixels from an image.
|
static Rectangle | getSelectedBounds(BufferedImage p) - Calculates the bounds of the non-transparent parts of the given image.
|
static BufferedImage | getSubimage(BufferedImage image, int x, int y, int w, int h) - Returns a *copy* of a subimage of image.
|
static void | paintCheckedBackground(Component c, Graphics g, int x, int y, int width, int height) - Paint a check pattern, used for a background to indicate image transparency.
|
static void | setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) - A convenience method for setting ARGB pixels in an image.
|
cloneImage
public static BufferedImage cloneImage(BufferedImage image)
Clones a BufferedImage.
image
- the image to clone
composeThroughMask
public static void composeThroughMask(Raster src,
WritableRaster dst,
Raster sel)
Compose src onto dst using the alpha of sel to interpolate between the two.
I can't think of a way to do this using AlphaComposite.
src
- the source rasterdst
- the destination rastersel
- the mask raster
convertImageToARGB
public static BufferedImage convertImageToARGB(Image image)
Convert an Image into a TYPE_INT_ARGB BufferedImage. If the image is already of this type, the original image is returned unchanged.
image
- the image to convert
createImage
public static BufferedImage createImage(ImageProducer producer)
Cretae a BufferedImage from an ImageProducer.
producer
- the ImageProducer
- a new TYPE_INT_ARGB BufferedImage
getRGB
public static int[] getRGB(BufferedImage image,
int x,
int y,
int width,
int height,
int[] pixels)
A convenience method for getting ARGB pixels from an image. This tries to avoid the performance
penalty of BufferedImage.getRGB unmanaging the image.
image
- a BufferedImage objectx
- the left edge of the pixel blocky
- the right edge of the pixel blockwidth
- the width of the pixel arryheight
- the height of the pixel arrypixels
- the array to hold the returned pixels. May be null.
getSelectedBounds
public static Rectangle getSelectedBounds(BufferedImage p)
Calculates the bounds of the non-transparent parts of the given image.
- the bounds of the non-transparent area
getSubimage
public static BufferedImage getSubimage(BufferedImage image,
int x,
int y,
int w,
int h)
Returns a *copy* of a subimage of image. This avoids the performance problems associated with BufferedImage.getSubimage.
image
- the imagex
- the x positiony
- the y positionw
- the widthh
- the height
paintCheckedBackground
public static void paintCheckedBackground(Component c,
Graphics g,
int x,
int y,
int width,
int height)
Paint a check pattern, used for a background to indicate image transparency.
c
- the component to draw intog
- the Graphics objectsx
- the x positiony
- the y positionwidth
- the widthheight
- the height
setRGB
public static void setRGB(BufferedImage image,
int x,
int y,
int width,
int height,
int[] pixels)
A convenience method for setting ARGB pixels in an image. This tries to avoid the performance
penalty of BufferedImage.setRGB unmanaging the image.
image
- a BufferedImage objectx
- the left edge of the pixel blocky
- the right edge of the pixel blockwidth
- the width of the pixel arryheight
- the height of the pixel arrypixels
- the array of pixels to set