java.awt.image

Class BufferedImage

Implemented Interfaces:
RenderedImage, Transparency, WritableRenderedImage

public class BufferedImage
extends Image
implements WritableRenderedImage, Transparency

A buffered image always starts at coordinates (0, 0). The buffered image is not subdivided into multiple tiles. Instead, the image consists of one large tile (0,0) with the width and height of the image. This tile is always considered to be checked out.

Field Summary

static int
TYPE_3BYTE_BGR
static int
TYPE_4BYTE_ABGR
static int
TYPE_4BYTE_ABGR_PRE
static int
TYPE_BYTE_BINARY
static int
TYPE_BYTE_GRAY
static int
TYPE_BYTE_INDEXED
static int
TYPE_CUSTOM
static int
TYPE_INT_ARGB
static int
TYPE_INT_ARGB_PRE
static int
TYPE_INT_BGR
static int
TYPE_INT_RGB
static int
TYPE_USHORT_555_RGB
static int
TYPE_USHORT_565_RGB
static int
TYPE_USHORT_GRAY

Fields inherited from class java.awt.Image

SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty, accelerationPriority

Fields inherited from interface java.awt.Transparency

BITMASK, OPAQUE, TRANSLUCENT

Constructor Summary

BufferedImage(int width, int height, int type)
Creates a new BufferedImage with the specified width, height and type.
BufferedImage(int w, int h, int type, IndexColorModel indexcolormodel)
BufferedImage(ColorModel colormodel, WritableRaster writableraster, boolean premultiplied, Hashtable properties)

Method Summary

void
addTileObserver(TileObserver to)
Adds a tile observer.
void
coerceData(boolean premultiplied)
WritableRaster
copyData(WritableRaster dest)
Graphics2D
createGraphics()
void
flush()
Flushes (that is, destroys) any resources used for this image.
WritableRaster
getAlphaRaster()
ColorModel
getColorModel()
Raster
getData()
Raster
getData(Rectangle rectangle)
Graphics
getGraphics()
Returns a graphics context object for drawing an off-screen object.
int
getHeight()
int
getHeight(ImageObserver imageobserver)
Returns the height of the image, or -1 if it is unknown.
int
getMinTileX()
int
getMinTileY()
int
getMinX()
int
getMinY()
int
getNumXTiles()
int
getNumYTiles()
Object
getProperty(String string)
Returns the value of the specified property, or Image.UndefinedProperty if the property is not defined.
Object
getProperty(String string, ImageObserver imageobserver)
This method requests a named property for an object.
String[]
getPropertyNames()
Returns null always.
int
getRGB(int x, int y)
int[]
getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scanlineStride)
WritableRaster
getRaster()
SampleModel
getSampleModel()
ImageProducer
getSource()
Returns the image producer object for this object.
Vector
getSources()
BufferedImage
getSubimage(int x, int y, int w, int h)
Raster
getTile(int tileX, int tileY)
int
getTileGridXOffset()
int
getTileGridYOffset()
int
getTileHeight()
int
getTileWidth()
int
getTransparency()
Return the transparency type.
int
getType()
int
getWidth()
int
getWidth(ImageObserver imageobserver)
Returns the width of the image, or -1 if it is unknown.
WritableRaster
getWritableTile(int tileX, int tileY)
Point[]
getWritableTileIndices()
boolean
hasTileWriters()
boolean
isAlphaPremultiplied()
boolean
isTileWritable(int tileX, int tileY)
void
releaseWritableTile(int tileX, int tileY)
void
removeTileObserver(TileObserver to)
Removes a tile observer.
void
setData(Raster src)
void
setRGB(int x, int y, int argb)
void
setRGB(int startX, int startY, int w, int h, int[] argbArray, int offset, int scanlineStride)
String
toString()
Convert this Object to a human-readable String.

Methods inherited from class java.awt.Image

flush, getAccelerationPriority, getGraphics, getHeight, getProperty, getScaledInstance, getSource, getWidth, setAccelerationPriority

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

TYPE_3BYTE_BGR

public static final int TYPE_3BYTE_BGR
Field Value:
5

TYPE_4BYTE_ABGR

public static final int TYPE_4BYTE_ABGR
Field Value:
6

TYPE_4BYTE_ABGR_PRE

public static final int TYPE_4BYTE_ABGR_PRE
Field Value:
7

TYPE_BYTE_BINARY

public static final int TYPE_BYTE_BINARY
Field Value:
12

TYPE_BYTE_GRAY

public static final int TYPE_BYTE_GRAY
Field Value:
10

TYPE_BYTE_INDEXED

public static final int TYPE_BYTE_INDEXED
Field Value:
13

TYPE_CUSTOM

public static final int TYPE_CUSTOM
Field Value:
0

TYPE_INT_ARGB

public static final int TYPE_INT_ARGB
Field Value:
2

TYPE_INT_ARGB_PRE

public static final int TYPE_INT_ARGB_PRE
Field Value:
3

TYPE_INT_BGR

public static final int TYPE_INT_BGR
Field Value:
4

TYPE_INT_RGB

public static final int TYPE_INT_RGB
Field Value:
1

TYPE_USHORT_555_RGB

public static final int TYPE_USHORT_555_RGB
Field Value:
9

TYPE_USHORT_565_RGB

public static final int TYPE_USHORT_565_RGB
Field Value:
8

TYPE_USHORT_GRAY

public static final int TYPE_USHORT_GRAY
Field Value:
11

Constructor Details

BufferedImage

public BufferedImage(int width,
                     int height,
                     int type)
Parameters:
width - the width (must be > 0).
height - the height (must be > 0).
type - the image type (see the list of valid types above).
Throws:
IllegalArgumentException - if width or height is less than or equal to zero.
IllegalArgumentException - if type is not one of the specified values.

BufferedImage

public BufferedImage(int w,
                     int h,
                     int type,
                     IndexColorModel indexcolormodel)

BufferedImage

public BufferedImage(ColorModel colormodel,
                     WritableRaster writableraster,
                     boolean premultiplied,
                     Hashtable properties)

Method Details

addTileObserver

public void addTileObserver(TileObserver to)
Adds a tile observer. If the observer is already present, it receives multiple notifications.
Specified by:
addTileObserver in interface WritableRenderedImage
Parameters:
to - The TileObserver to add.

coerceData

public void coerceData(boolean premultiplied)

copyData

public WritableRaster copyData(WritableRaster dest)
Specified by:
copyData in interface RenderedImage

createGraphics

public Graphics2D createGraphics()

flush

public void flush()
Flushes (that is, destroys) any resources used for this image. This includes the actual image data.
Overrides:
flush in interface Image

getAlphaRaster

public WritableRaster getAlphaRaster()

getColorModel

public ColorModel getColorModel()
Specified by:
getColorModel in interface RenderedImage

getData

public Raster getData()
Specified by:
getData in interface RenderedImage

getData

public Raster getData(Rectangle rectangle)
Specified by:
getData in interface RenderedImage

getGraphics

public Graphics getGraphics()
Returns a graphics context object for drawing an off-screen object. This method is only valid for off-screen objects.
Overrides:
getGraphics in interface Image
Returns:
a graphics context object for an off-screen object

getHeight

public int getHeight()
Specified by:
getHeight in interface RenderedImage

getHeight

public int getHeight(ImageObserver imageobserver)
Returns the height of the image, or -1 if it is unknown. If the image height is unknown, the observer object will be notified when the value is known.
Overrides:
getHeight in interface Image
Parameters:
Returns:
the height in pixels

getMinTileX

public int getMinTileX()
Specified by:
getMinTileX in interface RenderedImage

getMinTileY

public int getMinTileY()
Specified by:
getMinTileY in interface RenderedImage

getMinX

public int getMinX()
Specified by:
getMinX in interface RenderedImage

getMinY

public int getMinY()
Specified by:
getMinY in interface RenderedImage

getNumXTiles

public int getNumXTiles()
Specified by:
getNumXTiles in interface RenderedImage

getNumYTiles

public int getNumYTiles()
Specified by:
getNumYTiles in interface RenderedImage

getProperty

public Object getProperty(String string)
Returns the value of the specified property, or Image.UndefinedProperty if the property is not defined.
Specified by:
getProperty in interface RenderedImage
Parameters:
string - the property key (null not permitted).
Returns:
The property value.
Throws:
NullPointerException - if string is null.

getProperty

public Object getProperty(String string,
                          ImageObserver imageobserver)
This method requests a named property for an object. The value of the property is returned. The value UndefinedProperty is returned if there is no property with the specified name. The value null is returned if the properties for the object are not yet known. In this case, the specified image observer is notified when the properties are known.
Overrides:
getProperty in interface Image
Parameters:
Returns:
the named property, if available

getPropertyNames

public String[] getPropertyNames()
Returns null always.
Specified by:
getPropertyNames in interface RenderedImage
Returns:
null always.

getRGB

public int getRGB(int x,
                  int y)

getRGB

public int[] getRGB(int startX,
                    int startY,
                    int w,
                    int h,
                    int[] rgbArray,
                    int offset,
                    int scanlineStride)

getRaster

public WritableRaster getRaster()

getSampleModel

public SampleModel getSampleModel()
Specified by:
getSampleModel in interface RenderedImage

getSource

public ImageProducer getSource()
Returns the image producer object for this object. The producer is the object which generates pixels for this image.
Overrides:
getSource in interface Image
Returns:
the image producer for this object

getSources

public Vector getSources()
Specified by:
getSources in interface RenderedImage

getSubimage

public BufferedImage getSubimage(int x,
                                 int y,
                                 int w,
                                 int h)

getTile

public Raster getTile(int tileX,
                      int tileY)
Specified by:
getTile in interface RenderedImage

getTileGridXOffset

public int getTileGridXOffset()
Specified by:
getTileGridXOffset in interface RenderedImage

getTileGridYOffset

public int getTileGridYOffset()
Specified by:
getTileGridYOffset in interface RenderedImage

getTileHeight

public int getTileHeight()
Specified by:
getTileHeight in interface RenderedImage

getTileWidth

public int getTileWidth()
Specified by:
getTileWidth in interface RenderedImage

getTransparency

public int getTransparency()
Return the transparency type.
Specified by:
getTransparency in interface Transparency
Since:
1.5

getType

public int getType()

getWidth

public int getWidth()
Specified by:
getWidth in interface RenderedImage

getWidth

public int getWidth(ImageObserver imageobserver)
Returns the width of the image, or -1 if it is unknown. If the image width is unknown, the observer object will be notified when the value is known.
Overrides:
getWidth in interface Image
Parameters:
Returns:
the width in pixels

getWritableTile

public WritableRaster getWritableTile(int tileX,
                                      int tileY)
Specified by:
getWritableTile in interface WritableRenderedImage

getWritableTileIndices

public Point[] getWritableTileIndices()
Specified by:
getWritableTileIndices in interface WritableRenderedImage

hasTileWriters

public boolean hasTileWriters()
Specified by:
hasTileWriters in interface WritableRenderedImage

isAlphaPremultiplied

public boolean isAlphaPremultiplied()

isTileWritable

public boolean isTileWritable(int tileX,
                              int tileY)
Specified by:
isTileWritable in interface WritableRenderedImage

releaseWritableTile

public void releaseWritableTile(int tileX,
                                int tileY)
Specified by:
releaseWritableTile in interface WritableRenderedImage

removeTileObserver

public void removeTileObserver(TileObserver to)
Removes a tile observer. If the observer was not registered, nothing happens. If the observer was registered for multiple notifications, it is now registered for one fewer notification.
Specified by:
removeTileObserver in interface WritableRenderedImage
Parameters:
to - The TileObserver to remove.

setData

public void setData(Raster src)
Specified by:
setData in interface WritableRenderedImage

setRGB

public void setRGB(int x,
                   int y,
                   int argb)

setRGB

public void setRGB(int startX,
                   int startY,
                   int w,
                   int h,
                   int[] argbArray,
                   int offset,
                   int scanlineStride)

toString

public String toString()
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() and such.

It is typical, but not required, to ensure that this method never completes abruptly with a RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).

Overrides:
toString in interface Object
Returns:
the String representing this Object, which may be null

BufferedImage.java -- Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, Free Software Foundation This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.