📄 image acquisition and display.htm
字号:
<P><A name=52212>
<HR>
<CENTER><IMG
src="Image Acquisition and Display.files/Acquisition.doc.anc2.gif"></CENTER>
<HR>
</A><A name=52213>
<CENTER><FONT size=-1><B><I>Figure 4-2 </I><IMG
src="Image Acquisition and Display.files/sm-blank.gif" border=0>
BufferedImage</B></FONT></CENTER></A>
<P>As shown in <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Acquisition.doc.html#52213">Figure
4-2</A>, the combination of a <CODE>Raster</CODE> and a
<CODE>ColorModel</CODE> define a <CODE>BufferedImage</CODE>. The
<CODE>BufferedImage</CODE> class provides general image management for
immediate mode imaging.
<P>The <CODE>BufferedImage</CODE> class supports the following predefined
image types:
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B><A name=78521><I>Table 4-2 </I><IMG
src="Image Acquisition and Display.files/sm-blank.gif" border=0> Supported
Image Types </A></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TH><A name=78525>Name </A>
<TH><A name=78527>Description </A>
<TR vAlign=top>
<TD><A name=78529>TYPE_3BYTE_BGR</A><BR>
<TD><A name=78588>Represents an image with 8-bit RGB color components,
corresponding to a Windows-style BGR color model, with the colors blue,
green, and red stored in three bytes.</A><BR>
<TR vAlign=top>
<TD><A name=78533>TYPE_4BYTE_ABGR</A><BR>
<TD><A name=78606>Represents an image with 8-bit RGBA color components
with the colors blue, green, and red stored in three bytes and one byte
of alpha.</A><BR>
<TR vAlign=top>
<TD><A name=78537>TYPE_4BYTE_ABGR_PRE</A><BR>
<TD><A name=78619>Represents an image with 8-bit RGBA color components
with the colors blue, green, and red stored in three bytes and one byte
of alpha.</A><BR>
<TR vAlign=top>
<TD><A name=78541>TYPE_BYTE_BINARY</A><BR>
<TD><A name=78543>Represents an opaque byte-packed binary image.</A><BR>
<TR vAlign=top>
<TD><A name=78545>TYPE_BYTE_GRAY</A><BR>
<TD><A name=78547>Represents a unsigned byte grayscale image,
non-indexed.</A><BR>
<TR vAlign=top>
<TD><A name=78549>TYPE_BYTE_INDEXED</A><BR>
<TD><A name=78551>Represents an indexed byte image.</A><BR>
<TR vAlign=top>
<TD><A name=78553>TYPE_CUSTOM</A><BR>
<TD><A name=78555>Image type is not recognized so it must be a
customized image.</A><BR>
<TR vAlign=top>
<TD><A name=78557>TYPE_INT_ARGB</A><BR>
<TD><A name=78669>Represents an image with 8-bit RGBA color components
packed into integer pixels.</A><BR>
<TR vAlign=top>
<TD><A name=78561>TYPE_INT_ARGB_PRE</A><BR>
<TD><A name=78708>Represents an image with 8-bit RGB color components,
corresponding to a Windows- or Solaris- style BGR color model, with the
colors blue, green, and red packed into integer pixels.</A><BR>
<TR vAlign=top>
<TD><A name=78565>TYPE_INT_BGR</A><BR>
<TD><A name=78718>Represents an image with 8-bit RGB color components,
corresponding to a Windows- or Solaris- style BGR color model, with the
colors blue, green, and red packed into integer pixels.</A><BR>
<TR vAlign=top>
<TD><A name=78569>TYPE_INT_RGB</A><BR>
<TD><A name=78732>Represents an image with 8-bit RGB color components
packed into integer pixels.</A><BR>
<TR vAlign=top>
<TD><A name=78573>TYPE_USHORT_555_RGB</A><BR>
<TD><A name=78743>Represents an image with 5-5-5 RGB color components
(5-bits red, 5-bits green, 5-bits blue) with no alpha.</A><BR>
<TR vAlign=top>
<TD><A name=78577>TYPE_USHORT_565_RGB</A><BR>
<TD><A name=78750>Represents an image with 5-6-5 RGB color components
(5-bits red, 6-bits green, 5-bits blue) with no alpha.</A><BR>
<TR vAlign=top>
<TD><A name=78581>TYPE_USHORT_GRAY</A><BR>
<TD><A name=78583>Represents an unsigned short grayscale image,
non-indexed).</A><BR></TR></TBODY></TABLE>
<P>
<P><A name=52336>
<H2>4.2 <IMG src="Image Acquisition and Display.files/space.gif">JAI Image
Types</H2></A>The JAI API provides a set of classes for describing image data
of various kinds. These classes are organized into a class hierarchy, as shown
in <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Acquisition.doc.html#53019">Figure
4-3</A>.
<P><A name=53017>
<HR>
<CENTER><IMG
src="Image Acquisition and Display.files/Acquisition.doc.anc3.gif"></CENTER>
<HR>
</A><A name=53019>
<CENTER><FONT size=-1><B><I>Figure 4-3 </I><IMG
src="Image Acquisition and Display.files/sm-blank.gif" border=0> JAI Image
Type Hierarchy</B></FONT></CENTER></A>
<P><A name=77718>
<H3>4.2.1 <IMG src="Image Acquisition and Display.files/space.gif">Planar
Image</H3></A>The <CODE>PlanarImage</CODE> class is the main class for
defining two-dimensional images. The <CODE>PlanarImage</CODE> implements the
<CODE>java.awt.image.RenderedImage</CODE> interface, which describes a tiled,
read-only image with a pixel layout described by a <CODE>SampleModel</CODE>
and a <CODE>DataBuffer</CODE>. The <CODE>TiledImage</CODE> and
<CODE>OpImage</CODE> subclasses manipulate the instance variables they inherit
from <CODE>PlanarImage</CODE>, such as the image size, origin, tile
dimensions, and tile grid offsets, as well as the Vectors containing the
sources and sinks of the image.
<P>All non-JAI <CODE>RenderedImages</CODE> that are to be used in JAI must be
converted into <CODE>PlanarImages</CODE> by means of the
<CODE>RenderedImageAdapter</CODE> class and the
<CODE>WriteableRenderedImageAdapter</CODE> class. The
<CODE>wrapRenderedImage()</CODE> method provides a convenient interface to
both add a wrapper and take a snapshot if the image is writable. The standard
<CODE>PlanarImage</CODE> constructor used by <CODE>OpImages</CODE> performs
this wrapping automatically. Images that already extend
<CODE>PlanarImage</CODE> will be returned unchanged by
<CODE>wrapRenderedImage()</CODE>.
<P>Going in the other direction, existing code that makes use of the
<CODE>RenderedImage</CODE> interface will be able to use
<CODE>PlanarImage</CODE>s directly, without any changes or recompilation.
Therefore within JAI, images are returned from methods as
<CODE>PlanarImages</CODE>, even though incoming <CODE>RenderedImage</CODE>s
are accepted as arguments directly.
<P>
<TABLE border=0>
<TBODY>
<TR>
<TD><IMG src="Image Acquisition and Display.files/cistine.gif"></TD>
<TD>
<HR>
<B>API:</B> <CODE>javax.media.jai.PlanarImage </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>PlanarImage()
<P></P></LI></UL></PRE>
<DL><A name=77725>
<DT>
<DD>creates a <CODE>PlanarImage</CODE>. </A>
<P></P></DD></DL><PRE><UL>
<LI>static PlanarImage wrapRenderedImage(RenderedImage im)
<P></P></LI></UL></PRE>
<DL><A name=77727>
<DT>
<DD>wraps an arbitrary <CODE>RenderedImage</CODE> to produce a
<CODE>PlanarImage</CODE>. <CODE>PlanarImage</CODE> adds various properties
to an image, such as source and sink vectors and the ability to produce
snapshots, that are necessary for JAI. If the image is not a
<CODE>PlanarImage</CODE>, it is wrapped in a
<CODE>RenderedImageAdapter</CODE>. If the image implements
<CODE>WritableRenderedImage</CODE>, a snapshot is taken.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameters</EM>:
<P></P>
<TD><CODE>a</CODE>
<P></P>
<TD><CODE>RenderedImage</CODE> to be used as a synchronous source.
<P></P></TR></TBODY></TABLE>
<P></A>
<P></P></DD></DL><PRE><UL>
<LI>PlanarImage createSnapshot()
<P></P></LI></UL></PRE>
<DL><A name=77736>
<DT>
<DD>creates a snapshot, that is, a virtual copy of the image's current
contents. </A>
<P></P></DD></DL><PRE><UL>
<LI>Raster getData(Rectangle region)
<P></P></LI></UL></PRE>
<DL><A name=78986>
<DT>
<DD>returns a specified region of this image in a <CODE>Raster</CODE>.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameter</EM>:<EM></EM>
<P></P>
<TD><CODE>region</CODE>
<P></P>
<TD>The rectangular region of this image to be returned.
<P></P></TR></TBODY></TABLE>
<P></A>
<P></P></DD></DL><PRE><UL>
<LI>int getWidth()
<P></P></LI></UL></PRE>
<DL><A name=77738>
<DT>
<DD>returns the width of the image. </A>
<P></P></DD></DL><PRE><UL>
<LI>int getHeight()
<P></P></LI></UL></PRE>
<DL><A name=77740>
<DT>
<DD>returns the height of the image. </A>
<P></P></DD></DL><PRE><UL>
<LI>int getMinXCoord()
<P></P></LI></UL></PRE>
<DL><A name=77742>
<DT>
<DD>returns the X coordinate of the leftmost column of the image. </A>
<P></P></DD></DL><PRE><UL>
<LI>int getMaxXCoord()
<P></P></LI></UL></PRE>
<DL><A name=77744>
<DT>
<DD>returns the X coordinate of the rightmost column of the image. </A>
<P></P></DD></DL><PRE><UL>
<LI>int getMinYCoord()
<P></P></LI></UL></PRE>
<DL><A name=77746>
<DT>
<DD>returns the X coordinate of the uppermost row of the image. </A>
<P></P></DD></DL><PRE><UL>
<LI>int getMaxYCoord()
<P></P></LI></UL></PRE>
<DL><A name=77748>
<DT>
<DD>returns the X coordinate of the bottom row of the image. </A>
<P></P></DD></DL><PRE><UL>
<LI>Rectangle getBounds()
<P></P></LI></UL></PRE>
<DL><A name=77750>
<DT>
<DD>returns a Rectangle indicating the image bounds. </A>
<P></P></DD></DL><PRE><UL>
<LI>int getTileWidth()
<P></P></LI></UL></PRE>
<DL><A name=77752>
<DT>
<DD>returns the width of a tile. </A>
<P></P></DD></DL><PRE><UL>
<LI>int getTileHeight()
<P></P></LI></UL></PRE>
<DL><A name=77754>
<DT>
<DD>returns the height of a tile. </A>
<P></P></DD></DL><PRE><UL>
<LI>int tilesAcross()
<P></P></LI></UL></PRE>
<DL><A name=77756>
<DT>
<DD>returns the number of tiles along the tile grid in the horizontal
direction. Equivalent to <CODE>getMaxTileX() - getMinTileX() + 1</CODE>.
</A>
<P></P></DD></DL><PRE><UL>
<LI>int tilesDown()
<P></P></LI></UL></PRE>
<DL><A name=77758>
<DT>
<DD>returns the number of tiles along the tile grid in the vertical
direction. Equivalent to <CODE>getMaxTileY() - getMinTileY() + 1</CODE>.
</A>
<P></P></DD></DL>There are lots more methods.
<P><A name=52363>
<H3>4.2.2 <IMG src="Image Acquisition and Display.files/space.gif">Tiled
Image</H3></A>The JAI API expands on the tile data concept introduced in the
Java 2D API. In Java 2D, a tile is one of a set of rectangular regions that
span an image on a regular grid. The JAI API expands on the tile image with
the <CODE>TiledImage</CODE> class, which is the main class for writable images
in JAI.
<P>A tile represents all of the storage for its spatial region of the image.
If an image contains three bands, every tile represents all three bands of
storage. The use of tiled images improves application performance by allowing
the application to process an image region within a single tile without
bringing the entire image into memory.
<P><CODE>TiledImage</CODE> provides a straightforward implementation of the
<CODE>WritableRenderedImage</CODE> interface, taking advantage of that
interface's ability to describe images with multiple tiles. The tiles of a
<CODE>WritableRenderedImage</CODE> must share a <CODE>SampleModel</CODE>,
which determines their width, height, and pixel format.
<P>The tiles form a regular grid that may occupy any rectangular region of the
plane. Tile pixels that exceed the image's stated bounds have undefined
values.
<P>The contents of a <CODE>TiledImage</CODE> are defined by a single
<CODE>PlanarImage</CODE> source, provided either at construction time or by
means of the <CODE>set()</CODE> method. The <CODE>set()</CODE> method provides
a way to selectively overwrite a portion of a <CODE>TiledImage</CODE>,
possibly using a soft-edged mask.
<P><CODE>TiledImage</CODE> also supports direct manipulation of pixels by
means of the <CODE>getWritableTile</CODE> method. This method returns a
<CODE>WritableRaster</CODE> that can be modified directly. Such changes become
visible to readers according to the regular thread synchronization rules of
the Java virtual machine; JAI makes no additional guarantees. When a writer is
finished modifying a tile, it should call the <CODE>releaseWritableTile</CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -