public class DVBBufferedImage extends Image
DVBBufferedImage
subclass describes an Image
with
an accessible buffer of image data.
The DVBBufferedImage is an adapter class for java.awt.image.BufferedImage.
It supports two different platform dependent sample models TYPE_BASE and TYPE_ADVANCED.
Buffered images with the TYPE_BASE have the same sample model as the on screen graphics buffer, thus
TYPE_BASE could be CLUT based. TYPE_ADVANCED has a direct color model but it is not specified
how many bits are used to store the different color components.
By default, a new DVBBufferedImage is transparent. All alpha values are set to 0;
Instances of DVBBufferedImage shall be considered to be off-screen images for the
purpose of the inherited method Image.getGraphics
.Modifier and Type | Field and Description |
---|---|
static int |
TYPE_ADVANCED
Represents an image stored in a best possible SampleModel (platform dependent)
The image has a DirectColorModel
with alpha.
|
static int |
TYPE_BASE
Represents an image stored in a platform dependent Sample Model.
|
SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty
Constructor and Description |
---|
DVBBufferedImage(int width,
int height)
Constructs a DVBBufferedImage with the specified width and height.
|
DVBBufferedImage(int width,
int height,
int type)
Constructs a new DVBBufferedImage with the specified width and height
in the Sample Model specified by type.
|
Modifier and Type | Method and Description |
---|---|
DVBGraphics |
createGraphics()
Creates a
DVBGraphics , which can be used to draw into
this DVBBufferedImage . |
void |
dispose()
Disposes of this buffered image.
|
void |
flush()
Flushes all resources being used to cache optimization information.
|
Graphics |
getGraphics()
This method returns a
Graphics , it is here
for backwards compatibility. |
int |
getHeight()
Returns the height of the
DVBBufferedImage . |
int |
getHeight(ImageObserver observer)
Returns the height of the image.
|
Image |
getImage()
Returns a java.awt.Image representing this buffered image.
|
Object |
getProperty(String name,
ImageObserver observer)
Returns a property of the image by name.
|
int |
getRGB(int x,
int y)
Returns the specified 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 rectangular region of the image data.
|
Image |
getScaledInstance(int width,
int height,
int hints)
Creates a scaled version of this image.
|
ImageProducer |
getSource()
Returns the object that produces the pixels for the image.
|
DVBBufferedImage |
getSubimage(int x,
int y,
int w,
int h)
Returns a subimage defined by a specified rectangular region.
|
int |
getWidth()
Returns the width of the
DVBBufferedImage . |
int |
getWidth(ImageObserver observer)
Returns the width of the image.
|
void |
setRGB(int x,
int y,
int rgb)
Sets a pixel in this
DVBBufferedImage to the specified
ARGB 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 rectangular portion of the image data.
|
String |
toString()
Returns a
String representation of this
DVBBufferedImage object and its values. |
public static final int TYPE_ADVANCED
public static final int TYPE_BASE
public DVBBufferedImage(int width, int height)
width
- the width of the created imageheight
- the height of the created imagepublic DVBBufferedImage(int width, int height, int type)
width
- the width of the DVBBufferedImageheight
- the height of the DVBBufferedImagetype
- the ColorSpace of the DVBBufferedImagepublic DVBGraphics createGraphics()
DVBGraphics
, which can be used to draw into
this DVBBufferedImage
. Calls to this method after calls to the
dispose
method on the same instance shall return null.DVBGraphics
, used for drawing into this
image.public void flush()
dispose
method on the same instance shall fail silently.public Graphics getGraphics()
Graphics
, it is here
for backwards compatibility. createGraphics
is more
convenient, since it is declared to return a
DVBGraphics
. Calls to this method after calls to the
dispose
method on the same instance shall return null.getGraphics
in class Image
Graphics
, which can be used to draw into
this image.Graphics
,
Component.createImage(int, int)
public int getHeight()
DVBBufferedImage
.DVBBufferedImage
.public int getHeight(ImageObserver observer)
getHeight
in class Image
observer
- the ImageObserver
that receives
information about the image-1
if the height
is not yet known.Image.getWidth(ImageObserver)
,
ImageObserver
public Image getImage()
dispose
method on the same instance shall return null.public void dispose()
getGraphics
method may return null
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.
Calls to this method after calls to the
dispose
method on the same instance shall return null.getProperty
in class Image
name
- the property nameobserver
- the ImageObserver
that receives
notification regarding image informationObject
that is the property referred to by the
specified name
or null
if the
properties of this image are not yet known.ImageObserver
,
Image.UndefinedProperty
public int getRGB(int x, int y)
x
- the x-coordinate of the pixely
- the y-coordinate of the pixelArrayIndexOutOfBoundsException
- if x or y is out of bounds or if the dispose
method has been called on this instancepublic int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)
pixel = rgbArray[offset + (y-startY)*scansize + (x-startX)];
startX
- the x-coordinate of the upper-left corner of the
specified rectangular regionstartY
- the y-coordinate of the upper-left corner of the
specified rectangular regionw
- the width of the specified rectangular regionh
- the height of the specified rectangular regionrgbArray
- if not null
, the rgb pixels are
written hereoffset
- offset into the rgbArray
scansize
- scanline stride for the rgbArray
ArrayIndexOutOfBoundsException
- if the specified portion of the image
data is out of bounds or if the dispose method has been called on this instancepublic ImageProducer getSource()
getSource
in class Image
ImageProducer
that is used to produce the
pixels for this image.If the dispose
method has been called
on this instance then null shall be returned.
The source returned by this method is platform generated to provide access
to the current contents of the DVBBufferedImage
buffer.
ImageProducer
public DVBBufferedImage getSubimage(int x, int y, int w, int h) throws DVBRasterFormatException
DVBBufferedImage
shares the same
data array as the original image. If the dispose
method has been called
on this instance then null shall be returned.x
- the x-coordinate of the upper-left corner of the
specified rectangular regiony
- the y-coordinate of the upper-left corner of the
specified rectangular regionw
- the width of the specified rectangular regionh
- the height of the specified rectangular regionDVBBufferedImage
that is the subimage of this
DVBBufferedImage
.DVBRasterFormatException
- if the specified
area is not contained within this DVBBufferedImage
.public int getWidth()
DVBBufferedImage
.DVBBufferedImage
.public int getWidth(ImageObserver observer)
ImageObserver
is notified later and
-1
is returned.getWidth
in class Image
observer
- the ImageObserver
that receives
information about the image-1
if the width
is not yet known.Image.getHeight(ImageObserver)
,
ImageObserver
public void setRGB(int x, int y, int rgb)
DVBBufferedImage
to the specified
ARGB value. The pixel is assumed to be in the default RGB color
model, TYPE_INT_ARGB, and default sRGB color space. Calls to this method after
calls to the dispose
method on the same instance shall throw
an ArrayIndexOutOfBoundsException
.x
- the x-coordinate of the pixel to sety
- the y-coordinate of the pixel to setrgb
- the ARGB valuepublic void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)
pixel = rgbArray[offset + (y-startY)*scansize + (x-startX)];WARNING: No dithering takes place.
Calls to this method after
calls to the dispose
method on the same instance shall throw
an ArrayIndexOutOfBoundsException
.
startX
- the x-coordinate of the upper-left corner of the
specified rectangular regionstartY
- the y-coordinate of the upper-left corner of the
specified rectangular regionw
- the width of the specified rectangular regionh
- the height of the specified rectangular regionrgbArray
- the ARGB pixelsoffset
- offset into the rgbArray
scansize
- scanline stride for the rgbArray
public String toString()
String
representation of this
DVBBufferedImage
object and its values.public Image getScaledInstance(int width, int height, int hints)
Image
object is returned which will render
the image at the specified width
and
height
by default. The new Image
object
may be loaded asynchronously even if the original source image
has already been loaded completely. If either the width
or height
is a negative number then a value is
substituted to maintain the aspect ratio of the original image
dimensions. If the dispose
method has been called
on this instance then null shall be returned.getScaledInstance
in class Image
width
- the width to which to scale the image.height
- the height to which to scale the image.hints
- flags to indicate the type of algorithm to use
for image resampling.Image.SCALE_DEFAULT
,
Image.SCALE_FAST
,
Image.SCALE_SMOOTH
,
Image.SCALE_REPLICATE
,
Image.SCALE_AREA_AVERAGING
Copyright © 2012 CableLabs. All Rights Reserved.