public class Raster extends Object implements IDisposable
bands
, or sets of values, which are
most commonly associated with colors when the raster represents an image. For instance, a typical color image contains
three sets of values, or bands (red, green, and blue) which define the color of pixels within the image.
The following raster image formats can be read by the raster class:
BMP, ECW, IMG, JP2, NTF, NITF, PNG, SID, TIF, TIFF, JPG, JPEG, PPM, PGM, CLDS, and TGA.
The raster can also be loaded from memory, or constructed from a BufferedImage
.
To create a texture from a raster, pass it to the
Texture2DFactory.fromRaster(agi.foundation.graphics.imaging.Raster)
method.RasterStream
,
Rasters and Filtering topicConstructor and Description |
---|
Raster(BufferedImage bitmap)
Initializes a raster from a
BufferedImage . |
Raster(byte[] value,
RasterAttributes attributes)
Initializes a raster from memory.
|
Raster(Raster raster)
Initializes a raster from another raster.
|
Raster(String uri)
Initializes a raster from a Uri, which can be a file, HTTP, HTTPS, or FTP source.
|
Raster(String uri,
int x,
int y,
int width,
int height)
Initializes a raster from a Uri.
|
Raster(URI uri)
Initializes a raster from a Uri, which can be a file, HTTP, HTTPS, or FTP source.
|
Raster(URI uri,
int x,
int y,
int width,
int height)
Initializes a raster from a Uri.
|
Modifier and Type | Method and Description |
---|---|
Raster |
apply(RasterFilter filter)
Applies a
RasterFilter to the raster and returns a new raster with the results of the filtering. |
void |
applyInPlace(RasterFilter filter)
Applies a
RasterFilter to the raster. |
void |
copyFromBitmap(BufferedImage bitmap)
Copies a
BufferedImage into this raster. |
void |
copyFromMemory(byte[] value,
RasterAttributes attributes)
Copies the given memory into the raster.
|
void |
copyFromRaster(Raster raster)
Copies the data associated with the given
Raster into this raster. |
void |
dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting
unmanaged resources.
|
protected void |
dispose(boolean disposing) |
Raster |
extractBand(RasterBand band)
Extracts the band of raster data associated with the given
RasterBand . |
Raster |
extractBand(RasterFormat format)
Extracts the bands of raster data associated with the given
RasterFormat . |
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
void |
flip(FlipAxis axis)
Flips the raster along the given axis.
|
RasterAttributes |
getAttributes()
Gets the
RasterAttributes that define the raster data. |
int |
getHeight()
Gets the height of the raster in pixels.
|
int |
getWidth()
Gets the width of the raster in pixels.
|
void |
rotate(double angle)
Rotates the raster by the given angle.
|
void |
setAttributes(RasterAttributes value)
Gets the
RasterAttributes that define the raster data. |
BufferedImage |
toBitmap()
Copies the raster to a
BufferedImage
if the RasterFormat is supported. |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
public Raster(URI uri)
Raster
for a list of supported formats.uri
- The URI
of the raster.public Raster(String uri)
Raster
for a list of supported formats.uri
- The Uri of the raster.public Raster(URI uri, int x, int y, int width, int height)
Raster
for a list of supported formats.uri
- The URI
of the raster.x
- The X position of the subsection in pixels.y
- The Y position of the subsection in pixels.width
- The width of the subsection in pixels.height
- The height of the subsection in pixels.public Raster(String uri, int x, int y, int width, int height)
Raster
for a list of supported formats.uri
- The Uri of the raster.x
- The X position of the subsection in pixels.y
- The Y position of the subsection in pixels.width
- The width of the subsection in pixels.height
- The height of the subsection in pixels.public Raster(byte[] value, RasterAttributes attributes)
value
- The byte array that contains the raster data.attributes
- The RasterAttributes
that define the raster.public Raster(Raster raster)
raster
- The Raster
to create the raster from.public Raster(BufferedImage bitmap)
BufferedImage
. For best performance, use an image of type
bufferedimage.TYPE_3BYTE_BGR
,
bufferedimage.TYPE_INT_RGB
, or
bufferedimage.TYPE_INT_ARGB
. Images of other types will be converted automatically.bitmap
- The
BufferedImage
to create the raster from.protected void finalize() throws Throwable
java.lang.Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the Java™ virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
finalize
in class Object
Throwable
- the Exception
raised by this methodWeakReference
,
PhantomReference
public final void dispose()
IDisposable
dispose
in interface IDisposable
protected void dispose(boolean disposing)
public final RasterAttributes getAttributes()
RasterAttributes
that define the raster data.public final void setAttributes(RasterAttributes value)
RasterAttributes
that define the raster data.public final int getWidth()
public final int getHeight()
public final void flip(FlipAxis axis)
axis
- The axis along which the raster will be flipped.public final void rotate(double angle)
angle
- The angle in degrees by which the raster is rotated.public final Raster apply(RasterFilter filter)
RasterFilter
to the raster and returns a new raster with the results of the filtering. The current raster is not modified.filter
- The RasterFilter
to apply.Raster
with the results of the filtering.public final void applyInPlace(RasterFilter filter)
RasterFilter
to the raster. The current raster will contain the results of the filtering.filter
- The RasterFilter
to apply.public final BufferedImage toBitmap()
BufferedImage
if the RasterFormat
is supported. RGB, RGBA, BGR, and BGRA raster data is supported.BufferedImage
that contains the raster data.public final Raster extractBand(RasterBand band)
RasterBand
.band
- The RasterBand
to be extracted.public final Raster extractBand(RasterFormat format)
RasterFormat
.format
- The RasterFormat
associated with the bands to be extracted.public final void copyFromRaster(Raster raster)
Raster
into this raster.raster
- The Raster
to copy from.public final void copyFromMemory(byte[] value, RasterAttributes attributes)
value
- The byte array that contains the raster data to copy.attributes
- The RasterAttributes
that define the raster data being copied.public final void copyFromBitmap(BufferedImage bitmap)
BufferedImage
into this raster. For best performance, use an image of type
bufferedimage.TYPE_3BYTE_BGR
,
bufferedimage.TYPE_INT_RGB
, or
bufferedimage.TYPE_INT_ARGB
. Images of other types will be converted automatically.bitmap
- The
BufferedImage
to copy the data from.