| java.lang.Object java.awt.Image java.awt.image.BufferedImage
All known Subclasses: java.awt.X11Image,
BufferedImage | public class BufferedImage extends java.awt.Image (Code) | | The BufferedImage subclass describes an
Image with
an accessible buffer of image data.
A BufferedImage is comprised of a
ColorModel and a
Raster of image data.
The number and types of bands in the
SampleModel of the
Raster must match the number and types required by the
ColorModel to represent its color and alpha components.
All BufferedImage objects have an upper left corner
coordinate of (0, 0). Any Raster used to construct a
BufferedImage must therefore have minX=0 and minY=0.
See Also: ColorModel See Also: Raster See Also: WritableRaster version: 10 Feb 1997 |
Field Summary | |
final public static int | TYPE_BYTE_BINARY Represents an opaque byte-packed binary image. | final public static int | TYPE_BYTE_INDEXED Represents an indexed byte image. | final public static int | TYPE_CUSTOM Image type is not recognized so it must be a customized
image. | final public static int | TYPE_INT_ARGB Represents an image with 8-bit RGBA color components packed into
integer pixels. | final public static int | TYPE_INT_ARGB_PRE Represents an image with 8-bit RGBA color components packed into
integer pixels. | final public static int | TYPE_INT_BGR Represents an image with 8-bit RGB color components, corresponding
to a Windows- or Solaris- style BGR color model, with the colors
Blue, Green, and Red packed into integer pixels. | final public static int | TYPE_INT_RGB Represents an image with 8-bit RGB color components packed into
integer pixels. | final public static int | TYPE_USHORT_555_RGB Represents an image with 5-5-5 RGB color components (5-bits red,
5-bits green, 5-bits blue) with no alpha. | final public static int | TYPE_USHORT_565_RGB Represents an image with 5-6-5 RGB color components (5-bits red,
6-bits green, 5-bits blue) with no alpha. |
Method Summary | |
public Graphics2D | createGraphics() Creates a Graphics2D , which can be used to draw into
this BufferedImage . | public void | flush() Flushes all resources being used to cache optimization information. | public ColorModel | getColorModel() Returns the ColorModel . | public java.awt.Graphics | getGraphics() This method returns a
Graphics2D , but is here
for backwards compatibility. | public int | getHeight() Returns the height of the BufferedImage . | public int | getHeight(ImageObserver observer) Returns the actual height of the image. | public Object | getProperty(String name, ImageObserver observer) Returns a property of the image by name. | public Object | getProperty(String name) Returns a property of the image by name. | public String[] | getPropertyNames() Returns an array of names recognized by
BufferedImage.getProperty(String) getProperty(String) or null , if no property names are recognized. | public int | getRGB(int x, int y) Returns an integer pixel in the default RGB color model
(TYPE_INT_ARGB) and default sRGB colorspace. | public int[] | getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) Returns an array of integer pixels in the default RGB color model
(TYPE_INT_ARGB) and default sRGB color space,
from a portion of the image data. | public ImageProducer | getSource() Returns the object that produces the pixels for the image. | public BufferedImage | getSubimage(int x, int y, int w, int h) Returns a subimage defined by a specified rectangular region.
The returned BufferedImage shares the same
data array as the original image.
x, y the coordinates of the upper-left corner of thespecified rectangular region Parameters: w - the width of the specified rectangular region Parameters: h - the height of the specified rectangular region a BufferedImage that is the subimage of thisBufferedImage . | public int | getType() Returns the image type. | public int | getWidth() Returns the width of the BufferedImage . | public int | getWidth(ImageObserver observer) Returns the actual width of the image. | public synchronized void | setRGB(int x, int y, int rgb) Sets a pixel in this BufferedImage to the specified
RGB value. | public void | setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) Sets an array of integer pixels in the default RGB color model
(TYPE_INT_ARGB) and default sRGB color space,
into a portion of the image data. | public String | toString() Returns a String representation of this
BufferedImage object and its values. |
TYPE_BYTE_BINARY | final public static int TYPE_BYTE_BINARY(Code) | | Represents an opaque byte-packed binary image. The
image has an
IndexColorModel without alpha. When this
type is used as the imageType argument to the
BufferedImage constructor that takes an
imageType argument but no ColorModel
argument, an IndexColorModel is created with
two colors in the default sRGB ColorSpace :
{0, 0, 0} and {255, 255, 255}.
|
TYPE_BYTE_INDEXED | final public static int TYPE_BYTE_INDEXED(Code) | | Represents an indexed byte image. When this type is used as the
imageType argument to the BufferedImage
constructor that takes an imageType argument
but no ColorModel argument, an
IndexColorModel is created with
a 256-color 6/6/6 color cube palette with the rest of the colors
from 216-255 populated by grayscale values in the
default sRGB ColorSpace.
|
TYPE_CUSTOM | final public static int TYPE_CUSTOM(Code) | | Image type is not recognized so it must be a customized
image. This type is only used as a return value for the getType()
method.
|
TYPE_INT_ARGB | final public static int TYPE_INT_ARGB(Code) | | Represents an image with 8-bit RGBA color components packed into
integer pixels. The image has a DirectColorModel
with alpha. The color data in this image is considered not to be
premultiplied with alpha. When this type is used as the
imageType argument to a BufferedImage
constructor, the created image is consistent with images
created in the JDK1.1 and earlier releases.
|
TYPE_INT_ARGB_PRE | final public static int TYPE_INT_ARGB_PRE(Code) | | Represents an image with 8-bit RGBA color components packed into
integer pixels. The image has a DirectColorModel
with alpha. The color data in this image is considered to be
premultiplied with alpha.
|
TYPE_INT_BGR | final public static int TYPE_INT_BGR(Code) | | Represents an image with 8-bit RGB color components, corresponding
to a Windows- or Solaris- style BGR color model, with the colors
Blue, Green, and Red packed into integer pixels. There is no alpha.
The image has a
ComponentColorModel .
|
TYPE_INT_RGB | final public static int TYPE_INT_RGB(Code) | | Represents an image with 8-bit RGB color components packed into
integer pixels. The image has a
DirectColorModel without
alpha.
|
TYPE_USHORT_555_RGB | final public static int TYPE_USHORT_555_RGB(Code) | | Represents an image with 5-5-5 RGB color components (5-bits red,
5-bits green, 5-bits blue) with no alpha. This image has
a DirectColorModel .
|
TYPE_USHORT_565_RGB | final public static int TYPE_USHORT_565_RGB(Code) | | Represents an image with 5-6-5 RGB color components (5-bits red,
6-bits green, 5-bits blue) with no alpha. This image has
a DirectColorModel .
|
createGraphics | public Graphics2D createGraphics()(Code) | | Creates a Graphics2D , which can be used to draw into
this BufferedImage .
a Graphics2D , used for drawing into thisimage. |
flush | public void flush()(Code) | | Flushes all resources being used to cache optimization information.
The underlying pixel data is unaffected.
|
getColorModel | public ColorModel getColorModel()(Code) | | Returns the ColorModel .
the ColorModel of thisBufferedImage . |
getHeight | public int getHeight()(Code) | | Returns the height of the BufferedImage .
the height of this BufferedImage . |
getHeight | public int getHeight(ImageObserver observer)(Code) | | Returns the actual height of the image. If the height is not known
yet then the ImageObserver is notified later and
-1 is returned.
Parameters: observer - the ImageObserver that receivesinformation about the image the height of the image or -1 if the heightis not yet known. See Also: java.awt.Image.getWidth(ImageObserver) See Also: ImageObserver |
getProperty | public Object getProperty(String name, ImageObserver observer)(Code) | | Returns a property of the image by name. Individual property names
are defined by the various image formats. If a property is not
defined for a particular image, this method returns the
UndefinedProperty field. If the properties
for this image are not yet known, then this method returns
null and the ImageObserver object is
notified later. The property name "comment" should be used to
store an optional comment that can be presented to the user as a
description of the image, its source, or its author.
Parameters: name - the property name Parameters: observer - the ImageObserver that receivesnotification regarding image information an Object that is the property referred to by thespecified name or null if theproperties of this image are not yet known. See Also: ImageObserver See Also: java.awt.Image.UndefinedProperty |
getProperty | public Object getProperty(String name)(Code) | | Returns a property of the image by name.
Parameters: name - the property name an Object that is the property referred to bythe specified name . |
getPropertyNames | public String[] getPropertyNames()(Code) | | Returns an array of names recognized by
BufferedImage.getProperty(String) getProperty(String) or null , if no property names are recognized.
a String array containing all of the propertynames that getProperty(String) recognizes;or null if no property names are recognized. |
getRGB | public int getRGB(int x, int y)(Code) | | Returns an integer pixel in the default RGB color model
(TYPE_INT_ARGB) and default sRGB colorspace. Color
conversion takes place if this default model does not match
the image ColorModel . There are only 8-bits of
precision for each color component in the returned data when using
this method.
x, y the coordinates of the pixel from which to getthe pixel in the default RGB color model and sRGBcolor space an integer pixel in the default RGB color model anddefault sRGB colorspace. |
getRGB | public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)(Code) | | Returns an array of integer pixels in the default RGB color model
(TYPE_INT_ARGB) and default sRGB color space,
from a portion of the image data. Color conversion takes
place if the default model does not match the image
ColorModel . There are only 8-bits of precision for
each color component in the returned data when
using this method. With a specified coordinate (x, y) in the
image, the ARGB pixel can be accessed in this way:
pixel = rgbArray[offset + (y-startY)*scansize + (x-startX)];
startX, startY the starting coordinates Parameters: w - width of region Parameters: h - height of region Parameters: rgbArray - if not null , the rgb pixels arewritten here Parameters: offset - offset into the rgbArray Parameters: scansize - scanline stride for the rgbArray array of RGB pixels. IllegalArgumentException if an unknowndatatype is specified |
getSubimage | public BufferedImage getSubimage(int x, int y, int w, int h)(Code) | | Returns a subimage defined by a specified rectangular region.
The returned BufferedImage shares the same
data array as the original image.
x, y the coordinates of the upper-left corner of thespecified rectangular region Parameters: w - the width of the specified rectangular region Parameters: h - the height of the specified rectangular region a BufferedImage that is the subimage of thisBufferedImage . RasterFormatException if the specifiedarea is not contained within this BufferedImage . |
getWidth | public int getWidth()(Code) | | Returns the width of the BufferedImage .
the width of this BufferedImage . |
setRGB | public synchronized void setRGB(int x, int y, int rgb)(Code) | | Sets a pixel in this BufferedImage to the specified
RGB value. The pixel is assumed to be in the default RGB color
model, TYPE_INT_ARGB, and default sRGB color space. For images
with an IndexColorModel , the index with the nearest
color is chosen.
x, y the coordinates of the pixel to set Parameters: rgb - the RGB value |
setRGB | public void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)(Code) | | Sets an array of integer pixels in the default RGB color model
(TYPE_INT_ARGB) and default sRGB color space,
into a portion of the image data. Color conversion takes place
if the default model does not match the image
ColorModel . There are only 8-bits of precision for
each color component in the returned data when
using this method. With a specified coordinate (x, y) in the
this image, the ARGB pixel can be accessed in this way:
pixel = rgbArray[offset + (y-startY)*scansize + (x-startX)];
WARNING: No dithering takes place.
startX, startY the starting coordinates Parameters: w - width of the region Parameters: h - height of the region Parameters: rgbArray - the rgb pixels Parameters: offset - offset into the rgbArray Parameters: scansize - scanline stride for the rgbArray |
toString | public String toString()(Code) | | Returns a String representation of this
BufferedImage object and its values.
a String representing thisBufferedImage . |
|
|