java.awt.image
public class BufferedImage extends Image implements WritableRenderedImage, Transparency
Modifier and Type | Field and Description |
---|---|
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 |
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty
BITMASK, OPAQUE, TRANSLUCENT
Constructor and Description |
---|
BufferedImage(ColorModel colormodel,
WritableRaster writableraster,
boolean premultiplied,
Hashtable<?,?> properties) |
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) |
Modifier and Type | Method and Description |
---|---|
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. |
WritableRaster |
getRaster() |
int |
getRGB(int x,
int y) |
int[] |
getRGB(int startX,
int startY,
int w,
int h,
int[] rgbArray,
int offset,
int scanlineStride) |
SampleModel |
getSampleModel() |
ImageProducer |
getSource()
Returns the image producer object for this object.
|
Vector<RenderedImage> |
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.
|
getAccelerationPriority, getScaledInstance, setAccelerationPriority
public static final int TYPE_CUSTOM
public static final int TYPE_INT_RGB
public static final int TYPE_INT_ARGB
public static final int TYPE_INT_ARGB_PRE
public static final int TYPE_INT_BGR
public static final int TYPE_3BYTE_BGR
public static final int TYPE_4BYTE_ABGR
public static final int TYPE_4BYTE_ABGR_PRE
public static final int TYPE_USHORT_565_RGB
public static final int TYPE_USHORT_555_RGB
public static final int TYPE_BYTE_GRAY
public static final int TYPE_USHORT_GRAY
public static final int TYPE_BYTE_BINARY
public static final int TYPE_BYTE_INDEXED
public BufferedImage(int width, int height, int type)
BufferedImage
with the specified width, height
and type. Valid type
values are:
width
- the width (must be > 0).height
- the height (must be > 0).type
- the image type (see the list of valid types above).IllegalArgumentException
- if width
or
height
is less than or equal to zero.IllegalArgumentException
- if type
is not one of the
specified values.public BufferedImage(int w, int h, int type, IndexColorModel indexcolormodel)
public BufferedImage(ColorModel colormodel, WritableRaster writableraster, boolean premultiplied, Hashtable<?,?> properties)
public void coerceData(boolean premultiplied)
public WritableRaster copyData(WritableRaster dest)
copyData
in interface RenderedImage
public Graphics2D createGraphics()
public void flush()
Image
public WritableRaster getAlphaRaster()
public ColorModel getColorModel()
getColorModel
in interface RenderedImage
public Raster getData()
getData
in interface RenderedImage
public Raster getData(Rectangle rectangle)
getData
in interface RenderedImage
public Graphics getGraphics()
Image
getGraphics
in class Image
public int getHeight()
getHeight
in interface RenderedImage
public int getHeight(ImageObserver imageobserver)
Image
getHeight
in class Image
imageobserver
- the image observer for this objectImage.getWidth(ImageObserver)
public int getMinTileX()
getMinTileX
in interface RenderedImage
public int getMinTileY()
getMinTileY
in interface RenderedImage
public int getMinX()
getMinX
in interface RenderedImage
public int getMinY()
getMinY
in interface RenderedImage
public int getNumXTiles()
getNumXTiles
in interface RenderedImage
public int getNumYTiles()
getNumYTiles
in interface RenderedImage
public Object getProperty(String string)
Image.UndefinedProperty
if the property is not defined.getProperty
in interface RenderedImage
string
- the property key (null
not permitted).NullPointerException
- if string
is null
.public Object getProperty(String string, ImageObserver imageobserver)
Image
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.getProperty
in class Image
string
- the requested property nameimageobserver
- the image observer for this objectImage.UndefinedProperty
public String[] getPropertyNames()
null
always.getPropertyNames
in interface RenderedImage
null
always.public int getRGB(int x, int y)
public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scanlineStride)
public WritableRaster getRaster()
public SampleModel getSampleModel()
getSampleModel
in interface RenderedImage
public ImageProducer getSource()
Image
public Vector<RenderedImage> getSources()
getSources
in interface RenderedImage
public BufferedImage getSubimage(int x, int y, int w, int h)
public Raster getTile(int tileX, int tileY)
getTile
in interface RenderedImage
public int getTileGridXOffset()
getTileGridXOffset
in interface RenderedImage
public int getTileGridYOffset()
getTileGridYOffset
in interface RenderedImage
public int getTileHeight()
getTileHeight
in interface RenderedImage
public int getTileWidth()
getTileWidth
in interface RenderedImage
public int getType()
public int getWidth()
getWidth
in interface RenderedImage
public int getWidth(ImageObserver imageobserver)
Image
getWidth
in class Image
imageobserver
- the image observer for this objectImage.getHeight(ImageObserver)
public WritableRaster getWritableTile(int tileX, int tileY)
getWritableTile
in interface WritableRenderedImage
public Point[] getWritableTileIndices()
getWritableTileIndices
in interface WritableRenderedImage
public boolean hasTileWriters()
hasTileWriters
in interface WritableRenderedImage
public boolean isAlphaPremultiplied()
public boolean isTileWritable(int tileX, int tileY)
isTileWritable
in interface WritableRenderedImage
public void releaseWritableTile(int tileX, int tileY)
releaseWritableTile
in interface WritableRenderedImage
public void setData(Raster src)
setData
in interface WritableRenderedImage
public void setRGB(int x, int y, int argb)
public void setRGB(int startX, int startY, int w, int h, int[] argbArray, int offset, int scanlineStride)
public String toString()
Object
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())
.
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)
public void addTileObserver(TileObserver to)
addTileObserver
in interface WritableRenderedImage
to
- The TileObserver to add.public void removeTileObserver(TileObserver to)
removeTileObserver
in interface WritableRenderedImage
to
- The TileObserver to remove.public int getTransparency()
getTransparency
in interface Transparency
Transparency.OPAQUE
, Transparency.BITMASK
, or Transparency.TRANSLUCENT
.Transparency.getTransparency()