jcontrol.graphics
Class BufferedImage

java.lang.Object
  extended by jcontrol.graphics.BufferedImage
All Implemented Interfaces:
Image, Drawable

public class BufferedImage
extends Object
implements Image

The BufferedImage is an image that can be allocated and modified at runtime. To draw on the BufferedImage, a BufferGraphics object can be obtained via the getGraphics() method. A BufferedImage can be drawn to the display by using the display's drawImage() methods. The size of the buffer required to store the pixel values is width*height*2 bytes.

Example:
// this example draws a circle into a BufferedImage
//and shows it on the display.

BufferedImage image = new BufferedImage( 64, 64);
XGraphics imageGraphics = image.getGraphics();
imageGraphics.setForeground( 0xFFFF0000);
imageGraphics.drawOval( 0, 0, 64, 64);

Display d = new Display();
d.drawImage( image, 24, 24);

See Also:
BufferGraphics, Display

Constructor Summary
BufferedImage(int width, int height)
          Creates a new BufferedImage of the given size.
 
Method Summary
 void draw(Graphics graphics, int x, int y)
          Draws the BufferedImage to the specified coordinates.
 void draw(Graphics graphics, int x, int y, int width, int height, int xoff, int yoff)
          Draws a subimage of the BufferedImage to the specified coordinates.
 void draw(XGraphics graphics, int x, int y, int anchor)
          NOTE: not supported
Draws the BufferedImage to the specified coordinates with an anchor.
protected  void finalize()
          free internal data structures used by this bufferedimage object.
 XGraphics getGraphics()
          Returns an XGraphics object that can be used to draw on the BufferedImage.
 int getHeight()
          Returns the BufferedImage height.
 int getWidth()
          Returns the BufferedImage width.
 boolean isValid()
          Checks if the Image is properly configured and ready for use.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 

Constructor Detail

BufferedImage

public BufferedImage(int width,
                     int height)
Creates a new BufferedImage of the given size.

Parameters:
width - image width
height - image height
Method Detail

getGraphics

public XGraphics getGraphics()
Returns an XGraphics object that can be used to draw on the BufferedImage.

Returns:
XGraphics object (in fact a BufferGraphics object)

getHeight

public int getHeight()
Returns the BufferedImage height.

Specified by:
getHeight in interface Image
Returns:
image height

getWidth

public int getWidth()
Returns the BufferedImage width.

Specified by:
getWidth in interface Image
Returns:
image width

isValid

public boolean isValid()
Checks if the Image is properly configured and ready for use.

Specified by:
isValid in interface Image
Returns:
always true

draw

public void draw(Graphics graphics,
                 int x,
                 int y)
Draws the BufferedImage to the specified coordinates.

Specified by:
draw in interface Drawable
Parameters:
graphics - Graphics object to use for drawing
x - the horizontal coordinate
y - the vertical coordinate

draw

public void draw(Graphics graphics,
                 int x,
                 int y,
                 int width,
                 int height,
                 int xoff,
                 int yoff)
Draws a subimage of the BufferedImage to the specified coordinates.

Specified by:
draw in interface Drawable
Parameters:
graphics - Graphics object to use for drawing
x - the horizontal coordinate
y - the vertical coordinate
width - the width of the sub image within the source image
height - the height of the sub image within the source image
xoff - horizontal offset of the sub image within the source image
yoff - vertical offset of the sub image within the source image
See Also:
draw(Graphics, int, int)

draw

public void draw(XGraphics graphics,
                 int x,
                 int y,
                 int anchor)
NOTE: not supported
Draws the BufferedImage to the specified coordinates with an anchor.

Specified by:
draw in interface Image
Parameters:
x - the horizontal coordinate
y - the vertical coordinate
anchor - anchor
graphics - XGraphics to draw on
See Also:
XGraphics

finalize

protected void finalize()
free internal data structures used by this bufferedimage object.