📄 java awt imaging.htm
字号:
<TH><A name=52243>Name </A>
<TH><A name=52245>Description </A>
<TR vAlign=top>
<TD rowSpan=4><A name=52205>Class</A><BR>
<TD><A name=52207>DataBuffer</A><BR>
<TD><A name=52289>Extends: Object</A><BR><A name=52209>Wraps one or more
data arrays. Each data array in the DataBuffer is referred to as a
bank.</A><BR>
<TR vAlign=top>
<TD><A name=52265>Raster</A><BR>
<TD><A name=52267>Extends: Object</A><BR><A name=52287>Represents a
rectanglular array of pixels and provides methods for retrieving image
data.</A><BR>
<TR vAlign=top>
<TD><A name=53562>SampleModel</A><BR>
<TD><A name=53566>Extends: Object</A><BR><A name=53564>Extracts samples
of pixels in images.</A><BR>
<TR vAlign=top>
<TD><A name=52219>WriteableRaster</A><BR>
<TD><A name=52221>Extends: Raster</A><BR><A name=52277>Provides methods
for storing image data and inherits methods for retrieving image data
from it's parent class Raster.</A><BR></TR></TBODY></TABLE>
<P>The basic unit of image data storage is the <CODE>DataBuffer</CODE>. The
<CODE>DataBuffer</CODE> is a kind of raw storage that contains all of the
samples for the image data but does not maintain a notion of how those samples
can be put together as pixels. The information about how the samples are put
together as pixels is contained in a <CODE>SampleModel</CODE>. The
<CODE>SampleModel</CODE> class contains methods for deriving pixel data from a
<CODE>DataBuffer</CODE>. Together, a <CODE>DataBuffer</CODE> and a
<CODE>SampleModel</CODE> constitute a meaningful multi-pixel image storage
unit called a <CODE>Raster</CODE>.
<P>A <CODE>Raster</CODE> has methods that directly return pixel data for the
image data it contains. There are two basic types of <CODE>Raster</CODE>s:
<P>
<UL>
<LI><CODE>Raster</CODE> - a read-only object that has only accessors
<P></P></LI></UL>
<UL>
<LI><CODE>WritableRaster</CODE> - A writable object that has a variety of
mutators
<P></P></LI></UL>There are separate interfaces for dealing with each raster
type. The <CODE>RenderedImage</CODE> interface assumes that the data is
read-only and does not contain methods for writing a <CODE>Raster</CODE>. The
<CODE>WritableRenderedImage</CODE> interface assumes that the image data is
writeable and can be modified.
<P>Data from a <EM>tile</EM> is returned in a <CODE>Raster</CODE> object. A
tile is not a class in the architecture; it is a concept. A tile is one of a
set of regular rectangular regions that span the image on a regular grid. In
the <CODE>RenderedImage</CODE> interface, there are several methods that
relate to tiles and a tile grid. These methods are used by the JAI API, rather
than the Java 2D API. In the Java 2D API, the implementation of the
<CODE>WritableRenderedImage</CODE> (<CODE>BufferedImage</CODE>) is defined to
have a single tile. This, the <CODE>getWritableTile</CODE> method will return
all the image data. Other methods that relate to tiling will return the
correct degenerative results.
<P><CODE>RenderedImage</CODE>s do not necessarily maintain a
<CODE>Raster</CODE> internally. Rather, they can return requested rectangles
of image data in the form of a (<CODE>Writable</CODE>)<CODE>Raster</CODE>
(through the <CODE>getData</CODE>, <CODE>getRect</CODE>, and
<CODE>get</CODE>(<CODE>Writable</CODE>)<CODE>Tile</CODE> methods). This
distinction allows <CODE>RenderedImages</CODE> to be virtual images, producing
data only when needed. <CODE>RenderedImage</CODE>s do, however, have an
associated <CODE>SampleModel</CODE>, implying that data returned in
<CODE>Raster</CODE>s from the same image will always be written to the
associated <CODE>DataBuffer</CODE> in the same way.
<P>The Java 2D <CODE>BufferedImage</CODE> also adds an associated
<CODE>ColorModel</CODE>, which is different from the <CODE>SampleModel</CODE>.
The <CODE>ColorModel</CODE> determines how the bands are interpreted in a
colorimetric sense.
<P><A name=52335>
<H2>2.5 <IMG src="Java AWT Imaging.files/space.gif">Introducing the Java
Advanced Imaging API</H2></A>The JAI API builds on the foundation of the Java
2D API to allow more powerful and general imaging applications. The JAI API
adds the following concepts:
<P>
<UL>
<LI>Multi-tiled images
<P></P></LI></UL>
<UL>
<LI>Deferred execution
<P></P></LI></UL>
<UL>
<LI>Networked images
<P></P></LI></UL>
<UL>
<LI>Image property management
<P></P></LI></UL>
<UL>
<LI>Image operators with multiple sources
<P></P></LI></UL>
<UL>
<LI>Three-dimensional image data
<P></P></LI></UL>The combination of tiling and deferred execution allows for
considerable run-time optimization while maintaining a simple imaging model
for programmers. New operators may be added and the new operators may
participate as first-class objects in the deferred execution model.
<P>The JAI API also provides for a considerable degree of compatibility with
the Java AWT and Java 2D imaging models. JAI's operators can work directly on
Java 2D <CODE>BufferedImage</CODE> objects or any other image objects that
implement the <CODE>RenderedImage</CODE> interface. JAI supports the same
rendering-independent model as the Java 2D API. using device-independent
coordinates. JAI also supports Java 2D-style drawing on both Rendered and
Renderable images using the <CODE>Graphics</CODE> interface.
<P>The JAI API does not make use of the image producer/consumer interfaces
introduced in Java AWT and carried forward into the Java 2D API. Instead, the
JAI API requires that image sources participate in the "pull" imaging model by
responding to requests for arbitrary areas, thus making it impossible to
instantiate an <CODE>ImageProducer</CODE> directly as a source. It is,
however, possible to instantiate an <CODE>ImageProducer</CODE> that makes the
JAI API image data available to older AWT applications.
<P><A name=52401>
<H3>2.5.1 <IMG src="Java AWT Imaging.files/space.gif">Similarities with the
Java 2D API</H3></A>The JAI API is heavily dependent on the abstractions
defined in the Java 2D API. In general, the entire mechanism for handling
Renderable and Rendered images, pixel samples, and data storage is carried
over into JAI. Here are some of the major points of congruity between Java 2D
and JAI:
<P>
<UL>
<LI>The <CODE>RenderableImage</CODE> and <CODE>RenderedImage</CODE>
interfaces defined in the Java 2D API are used as a basis for higher-level
abstractions. Further, JAI allows you to create and manipulate directed
acyclic graphs of objects implementing these interfaces.
<P></P></LI></UL>
<UL>
<LI>The primary data object, the <CODE>TiledImage</CODE>, implements the
<CODE>WritableRenderedImage</CODE> interface and can contain a regular tile
grid of <CODE>Raster</CODE> objects. However, unlike the
<CODE>BufferedImage</CODE> of the Java 2D API, <CODE>TiledImage</CODE> does
not require that a <CODE>ColorModel</CODE> for photometric interpretation of
its image data be present.
<P></P></LI></UL>
<UL>
<LI>The JAI operator objects are considerably more sophisticated than in the
Java 2D API. The <CODE>OpImage</CODE>, the fundamental operator object,
provides considerable support for extensibility to new operators beyone that
in the Java 2D API. JAI has a registry mechanism that automates the
selection of operations on <CODE>RenderedImages</CODE>.
<P></P></LI></UL>
<UL>
<LI>The Java 2D API <CODE>SampleModel</CODE>, <CODE>DataBuffer</CODE>, and
<CODE>Raster</CODE> objects are carried over into JAI without change, except
that <CODE>double</CODE>s and <CODE>float</CODE>s are allows to be used as
the fundamental data types of a <CODE>DataBuffer</CODE> in addition to the
<CODE>byte</CODE>, <CODE>short</CODE>, and <CODE>int</CODE> data types.
<P></P></LI></UL><A name=52719>
<H3>2.5.2 <IMG src="Java AWT Imaging.files/space.gif">JAI Data
Classes</H3></A>JAI introduces two new data classes, which extend the Java 2D
<CODE>DataBuffer</CODE> image data class.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B><A name=52723><I>Table 2-7 </I><IMG
src="Java AWT Imaging.files/sm-blank.gif" border=0> JAI Data Classes
</A></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TH><A name=52747>Type </A>
<TH><A name=52749>Name </A>
<TH><A name=52751>Description </A>
<TR vAlign=top>
<TD rowSpan=2><A name=52735>Class</A><BR>
<TD><A name=52737>DataBufferFloat</A><BR>
<TD><A name=52745>Extends: DataBuffer</A><BR><A name=52787>Stores data
internally in float form.</A><BR>
<TR vAlign=top>
<TD><A name=52804>DataBufferDouble</A><BR>
<TD><A name=52806>Extends: DataBuffer</A><BR><A name=52807>Stores data
internally in double form.</A><BR></TR></TBODY></TABLE>
<P><A name=52800>
<H4>2.5.2.1 <IMG src="Java AWT Imaging.files/space.gif">The DataBufferFloat
Class</H4></A>
<TABLE border=0>
<TBODY>
<TR>
<TD><IMG src="Java AWT Imaging.files/cistine.gif"></TD>
<TD>
<HR>
<B>API:</B> <CODE>javax.media.jai.DataBufferFloat </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>DataBufferFloat(int size)
<P></P></LI></UL></PRE>
<DL><A name=52835>
<DT>
<DD>constructs a float-based DataBuffer with a specified size.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameters</EM>:<EM></EM>
<P></P>
<TD><CODE>size</CODE>
<P></P>
<TD>The number of elements in the <CODE>DataBuffer</CODE>.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>DataBufferFloat(int size, int numBanks)
<P></P></LI></UL></PRE>
<DL><A name=52869>
<DT>
<DD>constructs a float-based DataBuffer with a specified number of banks,
all of which are of a specified size.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=2><EM>Parameters</EM>:<EM></EM>
<P></P>
<TD><CODE>size</CODE>
<P></P>
<TD>The number of elements in each bank of the
<CODE>DataBuffer</CODE>.
<P></P>
<TR vAlign=top>
<TD><CODE>numBanks</CODE>
<P></P>
<TD>The number of banks in the <CODE>DataBuffer</CODE>.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>DataBufferFloat(float[] dataArray, int size)
<P></P></LI></UL></PRE>
<DL><A name=52920>
<DT>
<DD>constructs a float-based <CODE>DataBuffer</CODE> with the specified data
array. Only the first size elements are available for use by this data
buffer. The array must be large enough to hold <CODE>size</CODE> elements.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=2><EM>Parameters</EM>:<EM></EM>
<P></P>
<TD><CODE>dataArray</CODE>
<P></P>
<TD>An array of floats to be used as the first and only bank of this
<CODE>DataBuffer</CODE>.
<P></P>
<TR vAlign=top>
<TD><CODE>size</CODE>
<P></P>
<TD>The number of elements of the array to be used.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>DataBufferFloat(float[] dataArray, int size, int offset)
<P></P></LI></UL></PRE>
<DL><A name=52984>
<DT>
<DD>constructs a float-based <CODE>DataBuffer</CODE> with the specified data
array. Only the elements between <CODE>offset</CODE> and
(<CODE>offset</CODE> + <CODE>size</CODE> - 1) are available for use by this
<CODE>DataBuffer</CODE>. The array must be large enough to hold
(<CODE>offset</CODE> + <CODE>size</CODE>) elements.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=3><EM>Parameters</EM>:
<P></P>
<TD><CODE>dataArray</CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -