📄 image acquisition and display.htm
字号:
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameters</EM>:
<P></P>
<TD><CODE>im</CODE>
<P></P>
<TD>A <CODE>RenderedImage</CODE> source to replace the current source.
<P></P></TR></TBODY></TABLE>
<P></A>
<P></P></DD></DL><PRE><UL>
<LI>void set(RenderedImage im, ROI roi)
<P></P></LI></UL></PRE>
<DL><A name=59604>
<DT>
<DD>overlays a given <CODE>RenderedImage</CODE> on top of the current
contents of the <CODE>TiledImage</CODE>. The source image must have a
<CODE>SampleModel</CODE> compatible with that of this image.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=2><EM>Parameters</EM>:
<P></P>
<TD><CODE>im</CODE>
<P></P>
<TD>A <CODE>RenderedImage</CODE> source to replace the current source.
<P></P>
<TR vAlign=top>
<TD><CODE>roi</CODE>
<P></P>
<TD>The region of interest.
<P></P></TR></TBODY></TABLE>
<P></A>
<P></P></DD></DL><PRE><UL>
<LI>Graphics2D createGraphics()
<P></P></LI></UL></PRE>
<DL><A name=52999>
<DT>
<DD>creates a <CODE>Graphics2D</CODE> object that can be used to paint text
and graphics onto the <CODE>TiledImage</CODE>. </A>
<P></P></DD></DL><A name=81240>
<H4>4.2.2.1 <IMG src="Image Acquisition and Display.files/space.gif">Tile
Cache</H4></A>The <CODE>TileCache</CODE> interface provides a central place
for <CODE>OpImage</CODE>s to cache tiles they have computed. The tile cache is
created with a given capacity (measured in tiles). By default, the tile
capacity for a new tile cache is 300 tiles. The default memory capacity
reserved for tile cache is 20M bytes.
<P>The <CODE>TileCache</CODE> to be used by a particular operation may be set
during construction, or by calling the <CODE>JAI.setTileCache</CODE> method.
This results in the provided tile cache being added to the set of common
rendering hints.
<P>The <CODE>TileScheduler</CODE> interface allows tiles to be scheduled for
computation. In various implementations, tile computation may make use of
multithreading and multiple simultaneous network connections for improved
performance.
<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 </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>static TileCache createTileCache(int tileCapacity,
long memCapacity)
<P></P></LI></UL></PRE>
<DL><A name=81433>
<DT>
<DD>constructs a <CODE>TileCache</CODE> with the given tile capacity in
tiles and memory capacity in bytes. Users may supply an instance of
<CODE>TileCache</CODE> to an operation by supplying a
<CODE>RenderingHint</CODE> with a <CODE>JAI.KEY_TILE_CACHE</CODE> key and
the desired <CODE>TileCache</CODE> instance as its value. Note that the
absence of a tile cache hint will result in the use of the
<CODE>TileCache</CODE> belonging to the default <CODE>JAI</CODE> instance.
To force an operation not to perform caching, a <CODE>TileCache</CODE>
instance with a tile capacity of 0 may be used.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=2><EM>Parameters</EM>
<P></P>
<TD><CODE>tileCapacity</CODE>
<P></P>
<TD>The tile capacity, in tiles.
<P></P>
<TR vAlign=top>
<TD><CODE>memCapacity</CODE>
<P></P>
<TD>The memory capacity, in bytes.
<P></P></TR></TBODY></TABLE>
<P></A>
<P></P></DD></DL><PRE><UL>
<LI>static TileCache createTileCache()
<P></P></LI></UL></PRE>
<DL><A name=81455>
<DT>
<DD>constructs a <CODE>TileCache</CODE> with the default tile capacity in
tiles and memory capacity in bytes. </A>
<P></P></DD></DL><PRE><UL>
<LI>void setTileCache(TileCache tileCache)
<P></P></LI></UL></PRE>
<DL><A name=81504>
<DT>
<DD>sets the <CODE>TileCache</CODE> to be used by this <CODE>JAI</CODE>
instance. The <CODE>tileCache</CODE> parameter will be added to the
<CODE>RenderingHints</CODE> of this JAI instance. </A>
<P></P></DD></DL><PRE><UL>
<LI>TileCache getTileCache()
<P></P></LI></UL></PRE>
<DL><A name=81506>
<DT>
<DD>returns the <CODE>TileCache</CODE> being used by this <CODE>JAI</CODE>
instance. </A>
<P></P></DD></DL><A name=81379>
<H4>4.2.2.2 <IMG src="Image Acquisition and Display.files/space.gif">Pattern
Tiles</H4></A>A pattern tile consists of a repeated pattern. The
<CODE>pattern</CODE> operation defines a pattern tile by specifying the width
and height; all other layout parameters are optional, and when not specified
are set to default values. Each tile of the destination image will be defined
by a reference to a shared instance of the pattern.
<P>The <CODE>pattern</CODE> operation takes three parameters:
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TH><A name=60563>Parameter </A>
<TH><A name=60565>Type </A>
<TH><A name=60567>Description </A>
<TR vAlign=top>
<TD><A name=60581>width</A><BR>
<TD><A name=60583>Integer</A><BR>
<TD><A name=60585>The width of the image in pixels.</A><BR>
<TR vAlign=top>
<TD><A name=60587>height</A><BR>
<TD><A name=60589>Integer</A><BR>
<TD><A name=60591>The height of the image in pixels.</A><BR>
<TR vAlign=top>
<TD><A name=60599>pattern</A><BR>
<TD><A name=60601>Raster</A><BR>
<TD><A name=60603>The Pattern pixel band values.</A><BR></TR></TBODY></TABLE>
<P>
<P><A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Acquisition.doc.html#79244">Listing
4-2</A> shows a code sample for a <CODE>pattern</CODE> operation.
<P><CAPTION><FONT size=-1><B><A name=79244>
<CENTER><FONT size=-1><B><I>Listing 4-2 </I><IMG
src="Image Acquisition and Display.files/sm-blank.gif" border=0> Example
Pattern Operation </B></FONT></CENTER></A>
<P></B></FONT></CAPTION>
<HR>
<TR valign="top"><TD><PRE> // Create the raster.
WritableRaster raster;
int[] bandOffsets = new int[3];
bandOffsets[0] = 2;
bandOffsets[1] = 1;
bandOffsets[2] = 0;
</PRE><TR valign="top"><TD><PRE> // width, height=64.
PixelInterleavedSampleModel sm;
sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, 100,
100, 3, 3*100, bandOffsets);
</PRE><TR valign="top"><TD><PRE> // Origin is 0,0.
WritableRaster pattern = Raster.createWritableRaster(sm,
new Point(0, 0));
int[] bandValues = new int[3];
bandValues[0] = 90;
bandValues[1] = 45;
bandValues[2] = 45
</PRE><TR valign="top"><TD><PRE> // Set values for the pattern raster.
for (int y = 0; y < pattern.getHeight(); y++) {
for (int x = 0; x < pattern.getWidth(); x++) {
pattern.setPixel(x, y, bandValues);
bandValues[1] = (bandValues[1]+1)%255;
bandValues[2] = (bandValues[2]+1)%255;
}
}
</PRE><TR valign="top"><TD><PRE> // Create a 100x100 image with the given raster.
PlanarImage im0 = (PlanarImage)JAI.create("pattern",
100, 100,
pattern);
</PRE>
<HR>
<P>
<P><A name=53341>
<H3>4.2.3 <IMG src="Image Acquisition and Display.files/space.gif">Snapshot
Image</H3></A>The <CODE>SnapshotImage</CODE> class represents the main
component of the deferred execution engine. A <CODE>SnapshotImage</CODE>
provides an arbitrary number of synchronous views of a possibly changing
<CODE>WritableRenderedImage</CODE>. <CODE>SnapshotImage</CODE> is responsible
for stabilizing changing sources to allow deferred execution of operations
dependent on such sources.
<P>Any <CODE>RenderedImage</CODE> may be used as the source of a
<CODE>SnapshotImage</CODE>. If the source is a
<CODE>WritableRenderedImage</CODE>, the <CODE>SnapshotImage</CODE> will
register itself as a <CODE>TileObserver</CODE> and make copies of tiles that
are about to change.
<P>Multiple versions of each tile are maintained internally, as long as they
are in demand. <CODE>SnapshotImage</CODE> is able to track demand and should
be able to simply forward requests for tiles to the source most of the time,
without the need to make a copy.
<P>When used as a source, calls to <CODE>getTile</CODE> will simply be passed
along to the source. In other words, <CODE>SnapshotImage</CODE> is completely
transparent. However, by calling <CODE>createSnapshot()</CODE> an instance of
a non-public <CODE>PlanarImage</CODE> subclass (called <CODE>Snapshot</CODE>
in this implementation) will be created and returned. This image will always
return tile data with contents as of the time of its construction.
<P><A name=54671>
<H4>4.2.3.1 <IMG src="Image Acquisition and Display.files/space.gif">Creating
a SnapshotImage</H4></A>This implementation of <CODE>SnapshotImage</CODE>
makes use of a doubly-linked list of <CODE>Snapshot</CODE> objects. A new
<CODE>Snapshot</CODE> is added to the tail of the list whenever
<CODE>createSnapshot()</CODE> is called. Each <CODE>Snapshot</CODE> has a
cache containing copies of any tiles that were writable at the time of its
construction, as well as any tiles that become writable between the time of
its construction and the construction of the next <CODE>Snapshot</CODE>.
<P><A name=54672>
<H4>4.2.3.2 <IMG src="Image Acquisition and Display.files/space.gif">Using
SnapshotImage with a Tile</H4></A>When asked for a tile, a
<CODE>Snapshot</CODE> checks its local cache and returns its version of the
tile if one is found. Otherwise, it forwards the request onto its successor.
This process continues until the latest Snapshot is reached; if it does not
contain a copy of the tile, the tile is requested from the real source image.
<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.SnapShotImage </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>SnapshotImage(PlanarImage source)
<P></P></LI></UL></PRE>
<DL><A name=57441>
<DT>
<DD>constructs a <CODE>SnapshotImage</CODE> from a <CODE>PlanarImage</CODE>
source.
<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>source</CODE>
<P></P>
<TD>a <CODE>PlanarImage</CODE> source.
<P></P></TR></TBODY></TABLE>
<P></A>
<P></P></DD></DL><PRE><UL>
<LI>Raster getTile(int tileX, int tileY)
<P></P></LI></UL></PRE>
<DL><A name=53425>
<DT>
<DD>returns a non-snapshotted tile from the source.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=2><EM>Parameters</EM>:
<P></P>
<TD><CODE>tileX</CODE>
<P></P>
<TD>the X index of the tile.
<P></P>
<TR vAlign=top>
<TD><CODE>tileY</CODE>
<P></P>
<TD>the Y index of the tile.
<P></P></TR></TBODY></TABLE>
<P></A>
<P></P></DD></DL><PRE><UL>
<LI>void tileUpdate(java.awt.image.WritableRenderedImage source,
int tileX, int tileY, boolean willBeWritable)
<P></P></LI></UL></PRE>
<DL><A name=54156>
<DT>
<DD>receives the information that a tile is either about to become writable,
or is about to become no longer writable.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=4><EM>Parameters</EM>:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -