|
JSR-62 (Final) | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--java.awt.Image
|
+--java.awt.image.BufferedImage
The BufferedImage subclass describes an Image with
an accessible buffer of image data.
All BufferedImage objects have an upper left corner
coordinate of (0, 0).
ColorModel| Field Summary | |
static int |
TYPE_BYTE_BINARY
Represents an opaque byte-packed binary image. |
static int |
TYPE_BYTE_INDEXED
Represents an indexed byte image. |
static int |
TYPE_CUSTOM
Image type is not recognized so it must be a customized image. |
static int |
TYPE_INT_ARGB
Represents an image with 8-bit RGBA color components packed into integer pixels. |
static int |
TYPE_INT_ARGB_PRE
Represents an image with 8-bit RGBA color components packed into integer pixels. |
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. |
static int |
TYPE_INT_RGB
Represents an image with 8-bit RGB color components packed into integer pixels. |
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. |
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. |
| Fields inherited from class java.awt.Image |
SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty |
| Method Summary | |
Graphics2D |
createGraphics()
Creates a Graphics2D, which can be used to draw into
this BufferedImage. |
void |
flush()
Flushes all resources being used to cache optimization information. |
ColorModel |
getColorModel()
Returns the ColorModel. |
Graphics |
getGraphics()
This method returns a Graphics2D, but is here
for backwards compatibility. |
int |
getHeight()
Returns the height of the BufferedImage. |
int |
getHeight(ImageObserver observer)
Returns the actual height of the image. |
Object |
getProperty(String name)
Returns a property of the image by name. |
Object |
getProperty(String name,
ImageObserver observer)
Returns a property of the image by name. |
String[] |
getPropertyNames()
Returns an array of names recognized by getProperty(String)
or null, if no property names are recognized. |
int |
getRGB(int x,
int y)
Returns an integer pixel in the default RGB color model (TYPE_INT_ARGB) and default sRGB colorspace. |
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. |
ImageProducer |
getSource()
Returns the object that produces the pixels for the image. |
BufferedImage |
getSubimage(int x,
int y,
int w,
int h)
Returns a subimage defined by a specified rectangular region. |
int |
getType()
Returns the image type. |
int |
getWidth()
Returns the width of the BufferedImage. |
int |
getWidth(ImageObserver observer)
Returns the actual width of the image. |
void |
setRGB(int x,
int y,
int rgb)
Sets a pixel in this BufferedImage to the specified
RGB value. |
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. |
String |
toString()
Returns a String representation of this
BufferedImage object and its values. |
| Methods inherited from class java.awt.Image |
getScaledInstance |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int TYPE_CUSTOM
public static final int TYPE_INT_RGB
DirectColorModel without
alpha.
public static final int TYPE_INT_ARGB
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.
public static final int TYPE_INT_ARGB_PRE
DirectColorModel
with alpha. The color data in this image is considered to be
premultiplied with alpha.
public static final int TYPE_INT_BGR
DirectColorModel.
public static final int TYPE_USHORT_565_RGB
DirectColorModel.
public static final int TYPE_USHORT_555_RGB
DirectColorModel.
public static final int TYPE_BYTE_BINARY
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}.
public static final int TYPE_BYTE_INDEXED
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.
| Method Detail |
public int getType()
BufferedImage.TYPE_INT_RGB,
TYPE_INT_ARGB,
TYPE_INT_ARGB_PRE,
TYPE_INT_BGR,
TYPE_BYTE_BINARY,
TYPE_BYTE_INDEXED,
TYPE_USHORT_565_RGB,
TYPE_USHORT_555_RGB,
TYPE_CUSTOMpublic ColorModel getColorModel()
ColorModel.
ColorModel of this
BufferedImage.
public int getRGB(int x,
int y)
ColorModel. There are only 8-bits of
precision for each color component in the returned data when using
this method.
public int[] getRGB(int startX,
int startY,
int w,
int h,
int[] rgbArray,
int offset,
int scansize)
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)];
w - width of regionh - height of regionrgbArray - if not null, the rgb pixels are
written hereoffset - offset into the rgbArrayscansize - scanline stride for the rgbArray
IllegalArgumentException - if an unknown
datatype is specified
public void setRGB(int x,
int y,
int rgb)
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.
rgb - the RGB value
public void setRGB(int startX,
int startY,
int w,
int h,
int[] rgbArray,
int offset,
int scansize)
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.
w - width of the regionh - height of the regionrgbArray - the rgb pixelsoffset - offset into the rgbArrayscansize - scanline stride for the rgbArraypublic int getWidth()
BufferedImage.
BufferedImage.public int getHeight()
BufferedImage.
BufferedImage.public int getWidth(ImageObserver observer)
ImageObserver is notified later and
-1 is returned.
getWidth in class Imageobserver - the ImageObserver that receives
information about the image
-1 if the width
is not yet known.Image.getHeight(ImageObserver),
ImageObserverpublic int getHeight(ImageObserver observer)
ImageObserver is notified later and
-1 is returned.
getHeight in class Imageobserver - the ImageObserver that receives
information about the image
-1 if the height
is not yet known.Image.getWidth(ImageObserver),
ImageObserverpublic ImageProducer getSource()
getSource in class ImageImageProducer that is used to produce the
pixels for this image.ImageProducer
public Object getProperty(String name,
ImageObserver observer)
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.
getProperty in class Imagename - the property nameobserver - the ImageObserver that receives
notification regarding image information
Object that is the property referred to by the
specified name or null if the
properties of this image are not yet known.ImageObserver,
Image.UndefinedPropertypublic Object getProperty(String name)
name - the property name
Object that is the property referred to by
the specified name.public void flush()
flush in class Imagepublic Graphics getGraphics()
Graphics2D, but is here
for backwards compatibility. createGraphics is more
convenient, since it is declared to return a
Graphics2D.
getGraphics in class ImageGraphics2D, which can be used to draw into
this image.Graphics,
Component.createImage(int, int)public Graphics2D createGraphics()
Graphics2D, which can be used to draw into
this BufferedImage.
Graphics2D, used for drawing into this
image.
public BufferedImage getSubimage(int x,
int y,
int w,
int h)
BufferedImage shares the same
data array as the original image.
w - the width of the specified rectangular regionh - the height of the specified rectangular region
BufferedImage that is the subimage of this
BufferedImage.
RasterFormatException - if the specified
area is not contained within this BufferedImage.public String toString()
String representation of this
BufferedImage object and its values.
toString in class ObjectString representing this
BufferedImage.public String[] getPropertyNames()
getProperty(String)
or null, if no property names are recognized.
String array containing all of the property
names that getProperty(String) recognizes;
or null if no property names are recognized.
|
JSR-62 (Final) | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||