⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apps.fm7.html

📁 IMAGEIO package 的使用说明jdk1.4新出的 包。有效改进图片读写方式。
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><title>Java Image I/O API Guide: 3 - Writing Image I/O Applications</title></head><body bgcolor="#ffffff"> <table summary="layout" width="100%"><tr><td><!-- Bug in Communicator w/font: NavBar text disappears for Times 14pt pref. --><!-- font size="-1" --> <a href="imageio_guideTOC.fm.html" tppabs="http://java.sun.com/j2se/1.4.2/docs/guide/imageio/spec/imageio_guideTOC.fm.html">CONTENTS</a> | <a href="apps.fm6.html" tppabs="http://java.sun.com/j2se/1.4.2/docs/guide/imageio/spec/apps.fm6.html">PREV</a> | <a href="apps.fm8.html" tppabs="http://java.sun.com/j2se/1.4.2/docs/guide/imageio/spec/apps.fm8.html">NEXT</a> <!-- | <a href="copyright.fm.html">INDEX</a>  --><!-- /font --></td><td align=right><i>Java<sup><font size="-1">TM</font></sup></font> Image I/O API Guide</i></td></tr></table><br> <p><hr size="8" width="35%" align="left" noshade><h2><a name="998282"><i>3.7	</i> Listening for Events</a></h2><blockquote><pre>As an image is being read or written, the plug-in may provide updates to the application. The application may provide one or more classes that implement interfaces from the <code>javax.image.event</code> package. Instances of these classes are then added to the <code>ImageReader</code> or <code>ImageWriter</code> being used. For example,class MyReadProgressListener implements IIOReadProgressListener {	public MyReadProgressListener() {}	public void imageStarted(ImageReader source) {		System.out.println(&#34;Started reading!&#34;);	}	// Other methods from IIOReadProgressListener omitted}IIOReadProgressListener listener = new MyReadProgressListener();reader.addIIOReadProgressListener(listener);</pre></blockquote><blockquote><a name="997179"><!-- --></a>As the <code>ImageReader.read</code> method progresses, methods on <code>listener</code> will be called at various times to indicate how much of the image has been read. Because these methods are being called while <code>ImageReader.read</code> is active, they must not call most methods from the same <code>ImageReader</code> object.  They may call <code>ImageReader.abort()</code>, which will cause  <code>ImageReader.read</code> to return even if it is only partially complete.<p></blockquote><br><h3><a name="997167"><!-- --></a><i>3.7.1	</i> The <code>IIOReadProgressListener</code> Interface</h3><blockquote><a name="997182"><!-- --></a>An <code>IIOReadProgressListener</code> may be used to provide simple status information during reading. An estimate of the percentage of completion of a read is provided, which may be used to update a Swing <code>JProgressBar</code> or other progress indicator, or to estimate the time remaining to read a large image.<p><a name="997258"><!-- --></a>The <code>imageStarted</code> method will be called at the start of the read. During the read, the <code>imageProgress</code> method will be called multiple times, each time with a different, increasing value for its <code>percentageDone</code> parameter. When the read is about to complete, the <code>imageComplete</code> method will be called.<p><a name="997183"><!-- --></a>Similarly, the <code>thumbnailStarted</code>, <code>thumbnailProgress</code>, and <code>thumbnailComplete</code> methods will be called during thumbnail reads.<p><a name="997243"><!-- --></a>Other methods exist to indicate the start and end of a sequence of image reads performed by the <code>ImageReader.readAll</code> method. Additionally, it is possible for an ongoing read to be aborted using the <code>ImageReader.abort</code> method; in this case, the listener&#39;s <code>readAborted</code> method will be called.<p></blockquote><br><h3><a name="997193"><!-- --></a><i>3.7.2	</i> The <code>IIOReadUpdateListener</code> Interface</h3><blockquote><a name="997263"><!-- --></a>An <code>IIOReadUpdateListener</code> provides more detailed information on the progress of an image read. Some image formats allow interlaced or progressive encoding, in which a subset of the pixel data is made available quickly, so that a crude version of the image may be displayed while the remainder of the pixel data is still being received and decoded. A typical scheme might begin by sending only every fourth row, and only every fourth pixel in each of those rows, so that the initial image requires only one sixteenth of the total amount of data to be transmitted and decoded. If interlacing were not used, only the top one-sixteenth of the image would be displayed in the same amount of time. Thus, a person viewing an interlaced image will be able to get a sense of its contents much sooner than if a traditional left-to-right, top-to-bottom order were used.<p><a name="997317"><!-- --></a>By implementing the methods of the <code>IIOReadUpdateListener</code> interface, an application class can receive notification when groups of possibly non-contiguous pixels are ready to be displayed. These methods also receive a reference to the <code>BufferedImage</code> that is in the process of being filled in, which may be used to refresh the display to include the newly decoded pixels.<p><a name="997288"><!-- --></a>When decoding an interlaced or progressive image, the decoding proceeds in multiple passes. At the start of each pass, the listener&#39;s <code>passStarted</code> method will be called to indicate the set of pixels that may be overwritten during the following pass. This estimate is conservative; not every pixel in the region will necessarily be updated during the pass. As the pass progresses, the <code>imageUpdate</code> method will be called with arguments describing the region of pixels that have receive new values. This region is described by the coordinates of its upper-left corner, its width and height, and the spacing between the pixels that make up the pass (in the example above, both parameters would be equal to 4 for the initial pass). When a pass has completed, the <code>passComplete</code> method is called. Similar methods allow the progress of thumbnail image reads to be tracked.<p></blockquote><br><h3><a name="997169"><!-- --></a><i>3.7.3	</i> The <code>IIOReadWarningListener</code> Interface</h3><blockquote><a name="997170"><!-- --></a>By attaching an <code>IIOReadWarningListener</code> to an <code>ImageReader</code>, information on non-fatal errors may be received. For example, a reader might detect a tag or chunk that should not be present. Even though the reader may choose to ignore the error and proceed with decoding, it may wish to inform the application that the input source was malformed, as this could indicate problems in the application that generated the images.<p><a name="997338"><!-- --></a><code>ImageReader</code>s may specify a set of <code>Locale</code>s for which they can provide localized warning messages. The set of available locales can be obtained from the reader&#39;s <code>getAvailableLocales</code> method. The desired locale should then be set by calling the reader&#39;s <code>setLocale</code> method prior to attaching the <code>IIOReadWarningListener</code>. Each listener will receive messages in the <code>Locale</code> that was in effect at the time it was attached to the reader.<p></blockquote><br><h3><a name="997342"><!-- --></a><i>3.7.4	</i> The <code>IIOWriteProgressListener</code> and <code>IIOWriteWarningListener</code> Interfaces</h3><blockquote><a name="997343"><!-- --></a>The <code>IIOWriteProgressListener</code> and <code>IIOWriteWarningListener</code> interfaces function similarly to their reader counterparts.<p></blockquote><br><hr><!-- Bug in Communicator w/font: NavBar text disappears for Times 14pt pref. --><!-- font size="-1" --> <a href="imageio_guideTOC.fm.html" tppabs="http://java.sun.com/j2se/1.4.2/docs/guide/imageio/spec/imageio_guideTOC.fm.html">CONTENTS</a> | <a href="apps.fm6.html" tppabs="http://java.sun.com/j2se/1.4.2/docs/guide/imageio/spec/apps.fm6.html">PREV</a> | <a href="apps.fm8.html" tppabs="http://java.sun.com/j2se/1.4.2/docs/guide/imageio/spec/apps.fm8.html">NEXT</a> <!-- | <a href="copyright.fm.html">INDEX</a>  --><!-- /font --><hr><font size="-1"><i><A HREF="copyright.fm.html" tppabs="http://java.sun.com/j2se/1.4.2/docs/guide/imageio/spec/copyright.fm.html">Copyright</a> &#169 2001 Sun Microsystems, Inc. All Rights Reserved.</i></font><!-- This HTML file was created with Quadralay WebWorks Publisher 3.5.0 --><!-- by Suzette Pelouch --><!-- Last updated: Fri Apr 27 11:22:59 2001 --> </body><script language="JavaScript" src="s_code_remote.js" tppabs="http://java.sun.com/js/omi/jsc/s_code_remote.js"></script></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -