commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r935812 [35/46] - in /websites/production/commons/content/proper/commons-imaging: ./ apidocs/ apidocs/org/apache/commons/imaging/ apidocs/org/apache/commons/imaging/class-use/ apidocs/org/apache/commons/imaging/color/ apidocs/org/apache/com...
Date Sun, 11 Jan 2015 12:33:28 GMT
Modified: websites/production/commons/content/proper/commons-imaging/xref/org/apache/commons/imaging/formats/gif/GifImageParser.html
==============================================================================
--- websites/production/commons/content/proper/commons-imaging/xref/org/apache/commons/imaging/formats/gif/GifImageParser.html (original)
+++ websites/production/commons/content/proper/commons-imaging/xref/org/apache/commons/imaging/formats/gif/GifImageParser.html Sun Jan 11 12:33:25 2015
@@ -504,602 +504,603 @@
 <a class="jxr_linenumber" name="L496" href="#L496">496</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Dimension(id.imageWidth, id.imageHeight);
 <a class="jxr_linenumber" name="L497" href="#L497">497</a>     }
 <a class="jxr_linenumber" name="L498" href="#L498">498</a> 
-<a class="jxr_linenumber" name="L499" href="#L499">499</a>     @Override
-<a class="jxr_linenumber" name="L500" href="#L500">500</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../../org/apache/commons/imaging/common/ImageMetadata.html">ImageMetadata</a> getMetadata(<strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/bytesource/ByteSource.html">ByteSource</a> byteSource, <strong class="jxr_keyword">final</strong> Map&lt;String, Object&gt; params)
-<a class="jxr_linenumber" name="L501" href="#L501">501</a>             <strong class="jxr_keyword">throws</strong> ImageReadException, IOException {
-<a class="jxr_linenumber" name="L502" href="#L502">502</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="L503" href="#L503">503</a>     }
-<a class="jxr_linenumber" name="L504" href="#L504">504</a> 
-<a class="jxr_linenumber" name="L505" href="#L505">505</a>     <strong class="jxr_keyword">private</strong> List&lt;String&gt; getComments(<strong class="jxr_keyword">final</strong> List&lt;GifBlock&gt; blocks) <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="L506" href="#L506">506</a>         <strong class="jxr_keyword">final</strong> List&lt;String&gt; result = <strong class="jxr_keyword">new</strong> ArrayList&lt;String&gt;();
-<a class="jxr_linenumber" name="L507" href="#L507">507</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> code = 0x21fe;
-<a class="jxr_linenumber" name="L508" href="#L508">508</a> 
-<a class="jxr_linenumber" name="L509" href="#L509">509</a>         <strong class="jxr_keyword">for</strong> (GifBlock block : blocks) {
-<a class="jxr_linenumber" name="L510" href="#L510">510</a>             <strong class="jxr_keyword">if</strong> (block.blockCode == code) {
-<a class="jxr_linenumber" name="L511" href="#L511">511</a>                 <strong class="jxr_keyword">final</strong> byte[] bytes = ((GenericGifBlock) block).appendSubBlocks();
-<a class="jxr_linenumber" name="L512" href="#L512">512</a>                 result.add(<strong class="jxr_keyword">new</strong> String(bytes, <span class="jxr_string">"US-ASCII"</span>));
-<a class="jxr_linenumber" name="L513" href="#L513">513</a>             }
-<a class="jxr_linenumber" name="L514" href="#L514">514</a>         }
-<a class="jxr_linenumber" name="L515" href="#L515">515</a> 
-<a class="jxr_linenumber" name="L516" href="#L516">516</a>         <strong class="jxr_keyword">return</strong> result;
-<a class="jxr_linenumber" name="L517" href="#L517">517</a>     }
-<a class="jxr_linenumber" name="L518" href="#L518">518</a> 
-<a class="jxr_linenumber" name="L519" href="#L519">519</a>     @Override
-<a class="jxr_linenumber" name="L520" href="#L520">520</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../../org/apache/commons/imaging/ImageInfo.html">ImageInfo</a> getImageInfo(<strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/bytesource/ByteSource.html">ByteSource</a> byteSource, <strong class="jxr_keyword">final</strong> Map&lt;String, Object&gt; params)
-<a class="jxr_linenumber" name="L521" href="#L521">521</a>             <strong class="jxr_keyword">throws</strong> ImageReadException, IOException {
-<a class="jxr_linenumber" name="L522" href="#L522">522</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/ImageContents.html">ImageContents</a> blocks = readFile(byteSource, false);
-<a class="jxr_linenumber" name="L523" href="#L523">523</a> 
-<a class="jxr_linenumber" name="L524" href="#L524">524</a>         <strong class="jxr_keyword">if</strong> (blocks == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L525" href="#L525">525</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read blocks"</span>);
-<a class="jxr_linenumber" name="L526" href="#L526">526</a>         }
-<a class="jxr_linenumber" name="L527" href="#L527">527</a> 
-<a class="jxr_linenumber" name="L528" href="#L528">528</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/GifHeaderInfo.html">GifHeaderInfo</a> bhi = blocks.gifHeaderInfo;
-<a class="jxr_linenumber" name="L529" href="#L529">529</a>         <strong class="jxr_keyword">if</strong> (bhi == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L530" href="#L530">530</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read Header"</span>);
-<a class="jxr_linenumber" name="L531" href="#L531">531</a>         }
-<a class="jxr_linenumber" name="L532" href="#L532">532</a> 
-<a class="jxr_linenumber" name="L533" href="#L533">533</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/ImageDescriptor.html">ImageDescriptor</a> id = (ImageDescriptor) findBlock(blocks.blocks,
-<a class="jxr_linenumber" name="L534" href="#L534">534</a>                 IMAGE_SEPARATOR);
-<a class="jxr_linenumber" name="L535" href="#L535">535</a>         <strong class="jxr_keyword">if</strong> (id == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L536" href="#L536">536</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read ImageDescriptor"</span>);
-<a class="jxr_linenumber" name="L537" href="#L537">537</a>         }
-<a class="jxr_linenumber" name="L538" href="#L538">538</a> 
-<a class="jxr_linenumber" name="L539" href="#L539">539</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/GraphicControlExtension.html">GraphicControlExtension</a> gce = (GraphicControlExtension) findBlock(
-<a class="jxr_linenumber" name="L540" href="#L540">540</a>                 blocks.blocks, GRAPHIC_CONTROL_EXTENSION);
-<a class="jxr_linenumber" name="L541" href="#L541">541</a> 
-<a class="jxr_linenumber" name="L542" href="#L542">542</a>         <em class="jxr_comment">// Prefer the size information in the ImageDescriptor; it is more</em>
-<a class="jxr_linenumber" name="L543" href="#L543">543</a>         <em class="jxr_comment">// reliable than the size information in the header.</em>
-<a class="jxr_linenumber" name="L544" href="#L544">544</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> height = id.imageHeight;
-<a class="jxr_linenumber" name="L545" href="#L545">545</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> width = id.imageWidth;
-<a class="jxr_linenumber" name="L546" href="#L546">546</a> 
-<a class="jxr_linenumber" name="L547" href="#L547">547</a>         <strong class="jxr_keyword">final</strong> List&lt;String&gt; comments = getComments(blocks.blocks);
-<a class="jxr_linenumber" name="L548" href="#L548">548</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> bitsPerPixel = (bhi.colorResolution + 1);
-<a class="jxr_linenumber" name="L549" href="#L549">549</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/ImageFormat.html">ImageFormat</a> format = ImageFormats.GIF;
-<a class="jxr_linenumber" name="L550" href="#L550">550</a>         <strong class="jxr_keyword">final</strong> String formatName = <span class="jxr_string">"GIF Graphics Interchange Format"</span>;
-<a class="jxr_linenumber" name="L551" href="#L551">551</a>         <strong class="jxr_keyword">final</strong> String mimeType = <span class="jxr_string">"image/gif"</span>;
-<a class="jxr_linenumber" name="L552" href="#L552">552</a>         <em class="jxr_comment">// we ought to count images, but don't yet.</em>
-<a class="jxr_linenumber" name="L553" href="#L553">553</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> numberOfImages = -1;
-<a class="jxr_linenumber" name="L554" href="#L554">554</a> 
-<a class="jxr_linenumber" name="L555" href="#L555">555</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> progressive = id.interlaceFlag;
-<a class="jxr_linenumber" name="L556" href="#L556">556</a> 
-<a class="jxr_linenumber" name="L557" href="#L557">557</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> physicalWidthDpi = 72;
-<a class="jxr_linenumber" name="L558" href="#L558">558</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">float</strong> physicalWidthInch = (<strong class="jxr_keyword">float</strong>) ((<strong class="jxr_keyword">double</strong>) width / (<strong class="jxr_keyword">double</strong>) physicalWidthDpi);
-<a class="jxr_linenumber" name="L559" href="#L559">559</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> physicalHeightDpi = 72;
-<a class="jxr_linenumber" name="L560" href="#L560">560</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">float</strong> physicalHeightInch = (<strong class="jxr_keyword">float</strong>) ((<strong class="jxr_keyword">double</strong>) height / (<strong class="jxr_keyword">double</strong>) physicalHeightDpi);
-<a class="jxr_linenumber" name="L561" href="#L561">561</a> 
-<a class="jxr_linenumber" name="L562" href="#L562">562</a>         <strong class="jxr_keyword">final</strong> String formatDetails = <span class="jxr_string">"Gif "</span> + ((<strong class="jxr_keyword">char</strong>) blocks.gifHeaderInfo.version1)
-<a class="jxr_linenumber" name="L563" href="#L563">563</a>                 + ((<strong class="jxr_keyword">char</strong>) blocks.gifHeaderInfo.version2)
-<a class="jxr_linenumber" name="L564" href="#L564">564</a>                 + ((<strong class="jxr_keyword">char</strong>) blocks.gifHeaderInfo.version3);
-<a class="jxr_linenumber" name="L565" href="#L565">565</a> 
-<a class="jxr_linenumber" name="L566" href="#L566">566</a>         <strong class="jxr_keyword">boolean</strong> transparent = false;
-<a class="jxr_linenumber" name="L567" href="#L567">567</a>         <strong class="jxr_keyword">if</strong> (gce != <strong class="jxr_keyword">null</strong> &amp;&amp; gce.transparency) {
-<a class="jxr_linenumber" name="L568" href="#L568">568</a>             transparent = <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="L569" href="#L569">569</a>         }
-<a class="jxr_linenumber" name="L570" href="#L570">570</a> 
-<a class="jxr_linenumber" name="L571" href="#L571">571</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> usesPalette = <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="L572" href="#L572">572</a>         <strong class="jxr_keyword">final</strong> ImageInfo.ColorType colorType = ImageInfo.ColorType.RGB;
-<a class="jxr_linenumber" name="L573" href="#L573">573</a>         <strong class="jxr_keyword">final</strong> ImageInfo.CompressionAlgorithm compressionAlgorithm = ImageInfo.CompressionAlgorithm.LZW;
-<a class="jxr_linenumber" name="L574" href="#L574">574</a> 
-<a class="jxr_linenumber" name="L575" href="#L575">575</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageInfo.html">ImageInfo</a>(formatDetails, bitsPerPixel, comments,
-<a class="jxr_linenumber" name="L576" href="#L576">576</a>                 format, formatName, height, mimeType, numberOfImages,
-<a class="jxr_linenumber" name="L577" href="#L577">577</a>                 physicalHeightDpi, physicalHeightInch, physicalWidthDpi,
-<a class="jxr_linenumber" name="L578" href="#L578">578</a>                 physicalWidthInch, width, progressive, transparent,
-<a class="jxr_linenumber" name="L579" href="#L579">579</a>                 usesPalette, colorType, compressionAlgorithm);
-<a class="jxr_linenumber" name="L580" href="#L580">580</a>     }
-<a class="jxr_linenumber" name="L581" href="#L581">581</a> 
-<a class="jxr_linenumber" name="L582" href="#L582">582</a>     @Override
-<a class="jxr_linenumber" name="L583" href="#L583">583</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> dumpImageFile(<strong class="jxr_keyword">final</strong> PrintWriter pw, <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/bytesource/ByteSource.html">ByteSource</a> byteSource)
-<a class="jxr_linenumber" name="L584" href="#L584">584</a>             <strong class="jxr_keyword">throws</strong> ImageReadException, IOException {
-<a class="jxr_linenumber" name="L585" href="#L585">585</a>         pw.println(<span class="jxr_string">"gif.dumpImageFile"</span>);
-<a class="jxr_linenumber" name="L586" href="#L586">586</a> 
-<a class="jxr_linenumber" name="L587" href="#L587">587</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/ImageInfo.html">ImageInfo</a> imageData = getImageInfo(byteSource);
-<a class="jxr_linenumber" name="L588" href="#L588">588</a>         <strong class="jxr_keyword">if</strong> (imageData == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L589" href="#L589">589</a>             <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L590" href="#L590">590</a>         }
-<a class="jxr_linenumber" name="L591" href="#L591">591</a> 
-<a class="jxr_linenumber" name="L592" href="#L592">592</a>         imageData.toString(pw, <span class="jxr_string">""</span>);
-<a class="jxr_linenumber" name="L593" href="#L593">593</a>         
-<a class="jxr_linenumber" name="L594" href="#L594">594</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/ImageContents.html">ImageContents</a> blocks = readFile(byteSource, false);
-<a class="jxr_linenumber" name="L595" href="#L595">595</a> 
-<a class="jxr_linenumber" name="L596" href="#L596">596</a>         pw.println(<span class="jxr_string">"gif.blocks: "</span> + blocks.blocks.size());
-<a class="jxr_linenumber" name="L597" href="#L597">597</a>         <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; blocks.blocks.size(); i++) {
-<a class="jxr_linenumber" name="L598" href="#L598">598</a>             <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/GifBlock.html">GifBlock</a> gifBlock = blocks.blocks.get(i);
-<a class="jxr_linenumber" name="L599" href="#L599">599</a>             <strong class="jxr_keyword">this</strong>.debugNumber(pw, <span class="jxr_string">"\t"</span> + i + <span class="jxr_string">" ("</span>
-<a class="jxr_linenumber" name="L600" href="#L600">600</a>                     + gifBlock.getClass().getName() + <span class="jxr_string">")"</span>,
-<a class="jxr_linenumber" name="L601" href="#L601">601</a>                     gifBlock.blockCode, 4);
-<a class="jxr_linenumber" name="L602" href="#L602">602</a>         }
-<a class="jxr_linenumber" name="L603" href="#L603">603</a> 
-<a class="jxr_linenumber" name="L604" href="#L604">604</a>         pw.println(<span class="jxr_string">""</span>);
-<a class="jxr_linenumber" name="L605" href="#L605">605</a> 
-<a class="jxr_linenumber" name="L606" href="#L606">606</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="L607" href="#L607">607</a>     }
-<a class="jxr_linenumber" name="L608" href="#L608">608</a> 
-<a class="jxr_linenumber" name="L609" href="#L609">609</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong>[] getColorTable(<strong class="jxr_keyword">final</strong> byte[] bytes) <strong class="jxr_keyword">throws</strong> ImageReadException {
-<a class="jxr_linenumber" name="L610" href="#L610">610</a>         <strong class="jxr_keyword">if</strong> ((bytes.length % 3) != 0) {
-<a class="jxr_linenumber" name="L611" href="#L611">611</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"Bad Color Table Length: "</span>
-<a class="jxr_linenumber" name="L612" href="#L612">612</a>                     + bytes.length);
-<a class="jxr_linenumber" name="L613" href="#L613">613</a>         }
-<a class="jxr_linenumber" name="L614" href="#L614">614</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> length = bytes.length / 3;
-<a class="jxr_linenumber" name="L615" href="#L615">615</a> 
-<a class="jxr_linenumber" name="L616" href="#L616">616</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong>[] result = <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[length];
-<a class="jxr_linenumber" name="L617" href="#L617">617</a> 
-<a class="jxr_linenumber" name="L618" href="#L618">618</a>         <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; length; i++) {
-<a class="jxr_linenumber" name="L619" href="#L619">619</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> red = 0xff &amp; bytes[(i * 3) + 0];
-<a class="jxr_linenumber" name="L620" href="#L620">620</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> green = 0xff &amp; bytes[(i * 3) + 1];
-<a class="jxr_linenumber" name="L621" href="#L621">621</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> blue = 0xff &amp; bytes[(i * 3) + 2];
-<a class="jxr_linenumber" name="L622" href="#L622">622</a> 
-<a class="jxr_linenumber" name="L623" href="#L623">623</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> alpha = 0xff;
-<a class="jxr_linenumber" name="L624" href="#L624">624</a> 
-<a class="jxr_linenumber" name="L625" href="#L625">625</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> rgb = (alpha &lt;&lt; 24) | (red &lt;&lt; 16) | (green &lt;&lt; 8) | (blue &lt;&lt; 0);
-<a class="jxr_linenumber" name="L626" href="#L626">626</a>             result[i] = rgb;
-<a class="jxr_linenumber" name="L627" href="#L627">627</a>         }
-<a class="jxr_linenumber" name="L628" href="#L628">628</a> 
-<a class="jxr_linenumber" name="L629" href="#L629">629</a>         <strong class="jxr_keyword">return</strong> result;
-<a class="jxr_linenumber" name="L630" href="#L630">630</a>     }
-<a class="jxr_linenumber" name="L631" href="#L631">631</a> 
-<a class="jxr_linenumber" name="L632" href="#L632">632</a>     @Override
-<a class="jxr_linenumber" name="L633" href="#L633">633</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../../org/apache/commons/imaging/FormatCompliance.html">FormatCompliance</a> getFormatCompliance(<strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/bytesource/ByteSource.html">ByteSource</a> byteSource)
-<a class="jxr_linenumber" name="L634" href="#L634">634</a>             <strong class="jxr_keyword">throws</strong> ImageReadException, IOException {
-<a class="jxr_linenumber" name="L635" href="#L635">635</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/FormatCompliance.html">FormatCompliance</a> result = <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/FormatCompliance.html">FormatCompliance</a>(
-<a class="jxr_linenumber" name="L636" href="#L636">636</a>                 byteSource.getDescription());
-<a class="jxr_linenumber" name="L637" href="#L637">637</a> 
-<a class="jxr_linenumber" name="L638" href="#L638">638</a>         readFile(byteSource, false, result);
-<a class="jxr_linenumber" name="L639" href="#L639">639</a> 
-<a class="jxr_linenumber" name="L640" href="#L640">640</a>         <strong class="jxr_keyword">return</strong> result;
-<a class="jxr_linenumber" name="L641" href="#L641">641</a>     }
-<a class="jxr_linenumber" name="L642" href="#L642">642</a> 
-<a class="jxr_linenumber" name="L643" href="#L643">643</a>     @Override
-<a class="jxr_linenumber" name="L644" href="#L644">644</a>     <strong class="jxr_keyword">public</strong> BufferedImage getBufferedImage(<strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/bytesource/ByteSource.html">ByteSource</a> byteSource, <strong class="jxr_keyword">final</strong> Map&lt;String, Object&gt; params)
-<a class="jxr_linenumber" name="L645" href="#L645">645</a>             <strong class="jxr_keyword">throws</strong> ImageReadException, IOException {
-<a class="jxr_linenumber" name="L646" href="#L646">646</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/ImageContents.html">ImageContents</a> imageContents = readFile(byteSource, false);
-<a class="jxr_linenumber" name="L647" href="#L647">647</a> 
-<a class="jxr_linenumber" name="L648" href="#L648">648</a>         <strong class="jxr_keyword">if</strong> (imageContents == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L649" href="#L649">649</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read blocks"</span>);
-<a class="jxr_linenumber" name="L650" href="#L650">650</a>         }
-<a class="jxr_linenumber" name="L651" href="#L651">651</a> 
-<a class="jxr_linenumber" name="L652" href="#L652">652</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/GifHeaderInfo.html">GifHeaderInfo</a> ghi = imageContents.gifHeaderInfo;
-<a class="jxr_linenumber" name="L653" href="#L653">653</a>         <strong class="jxr_keyword">if</strong> (ghi == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L654" href="#L654">654</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read Header"</span>);
-<a class="jxr_linenumber" name="L655" href="#L655">655</a>         }
-<a class="jxr_linenumber" name="L656" href="#L656">656</a> 
-<a class="jxr_linenumber" name="L657" href="#L657">657</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/ImageDescriptor.html">ImageDescriptor</a> id = (ImageDescriptor) findBlock(imageContents.blocks,
-<a class="jxr_linenumber" name="L658" href="#L658">658</a>                 IMAGE_SEPARATOR);
-<a class="jxr_linenumber" name="L659" href="#L659">659</a>         <strong class="jxr_keyword">if</strong> (id == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L660" href="#L660">660</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read Image Descriptor"</span>);
-<a class="jxr_linenumber" name="L661" href="#L661">661</a>         }
-<a class="jxr_linenumber" name="L662" href="#L662">662</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/GraphicControlExtension.html">GraphicControlExtension</a> gce = (GraphicControlExtension) findBlock(
-<a class="jxr_linenumber" name="L663" href="#L663">663</a>                 imageContents.blocks, GRAPHIC_CONTROL_EXTENSION);
-<a class="jxr_linenumber" name="L664" href="#L664">664</a> 
-<a class="jxr_linenumber" name="L665" href="#L665">665</a>         <em class="jxr_comment">// Prefer the size information in the ImageDescriptor; it is more</em>
-<a class="jxr_linenumber" name="L666" href="#L666">666</a>         <em class="jxr_comment">// reliable</em>
-<a class="jxr_linenumber" name="L667" href="#L667">667</a>         <em class="jxr_comment">// than the size information in the header.</em>
-<a class="jxr_linenumber" name="L668" href="#L668">668</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> width = id.imageWidth;
-<a class="jxr_linenumber" name="L669" href="#L669">669</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> height = id.imageHeight;
-<a class="jxr_linenumber" name="L670" href="#L670">670</a> 
-<a class="jxr_linenumber" name="L671" href="#L671">671</a>         <strong class="jxr_keyword">boolean</strong> hasAlpha = false;
-<a class="jxr_linenumber" name="L672" href="#L672">672</a>         <strong class="jxr_keyword">if</strong> (gce != <strong class="jxr_keyword">null</strong> &amp;&amp; gce.transparency) {
-<a class="jxr_linenumber" name="L673" href="#L673">673</a>             hasAlpha = <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="L674" href="#L674">674</a>         }
-<a class="jxr_linenumber" name="L675" href="#L675">675</a> 
-<a class="jxr_linenumber" name="L676" href="#L676">676</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/ImageBuilder.html">ImageBuilder</a> imageBuilder = <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/common/ImageBuilder.html">ImageBuilder</a>(width, height, hasAlpha);
-<a class="jxr_linenumber" name="L677" href="#L677">677</a> 
-<a class="jxr_linenumber" name="L678" href="#L678">678</a>         <strong class="jxr_keyword">int</strong>[] colorTable;
-<a class="jxr_linenumber" name="L679" href="#L679">679</a>         <strong class="jxr_keyword">if</strong> (id.localColorTable != <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L680" href="#L680">680</a>             colorTable = getColorTable(id.localColorTable);
-<a class="jxr_linenumber" name="L681" href="#L681">681</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (imageContents.globalColorTable != <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L682" href="#L682">682</a>             colorTable = getColorTable(imageContents.globalColorTable);
-<a class="jxr_linenumber" name="L683" href="#L683">683</a>         } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="L684" href="#L684">684</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"Gif: No Color Table"</span>);
-<a class="jxr_linenumber" name="L685" href="#L685">685</a>         }
-<a class="jxr_linenumber" name="L686" href="#L686">686</a> 
-<a class="jxr_linenumber" name="L687" href="#L687">687</a>         <strong class="jxr_keyword">int</strong> transparentIndex = -1;
-<a class="jxr_linenumber" name="L688" href="#L688">688</a>         <strong class="jxr_keyword">if</strong> (gce != <strong class="jxr_keyword">null</strong> &amp;&amp; hasAlpha) {
-<a class="jxr_linenumber" name="L689" href="#L689">689</a>             transparentIndex = gce.transparentColorIndex;
-<a class="jxr_linenumber" name="L690" href="#L690">690</a>         }
-<a class="jxr_linenumber" name="L691" href="#L691">691</a> 
-<a class="jxr_linenumber" name="L692" href="#L692">692</a>         <strong class="jxr_keyword">int</strong> counter = 0;
-<a class="jxr_linenumber" name="L693" href="#L693">693</a> 
-<a class="jxr_linenumber" name="L694" href="#L694">694</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> rowsInPass1 = (height + 7) / 8;
-<a class="jxr_linenumber" name="L695" href="#L695">695</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> rowsInPass2 = (height + 3) / 8;
-<a class="jxr_linenumber" name="L696" href="#L696">696</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> rowsInPass3 = (height + 1) / 4;
-<a class="jxr_linenumber" name="L697" href="#L697">697</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> rowsInPass4 = (height) / 2;
-<a class="jxr_linenumber" name="L698" href="#L698">698</a> 
-<a class="jxr_linenumber" name="L699" href="#L699">699</a>         <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> row = 0; row &lt; height; row++) {
-<a class="jxr_linenumber" name="L700" href="#L700">700</a>             <strong class="jxr_keyword">int</strong> y;
-<a class="jxr_linenumber" name="L701" href="#L701">701</a>             <strong class="jxr_keyword">if</strong> (id.interlaceFlag) {
-<a class="jxr_linenumber" name="L702" href="#L702">702</a>                 <strong class="jxr_keyword">int</strong> theRow = row;
-<a class="jxr_linenumber" name="L703" href="#L703">703</a>                 <strong class="jxr_keyword">if</strong> (theRow &lt; rowsInPass1) {
-<a class="jxr_linenumber" name="L704" href="#L704">704</a>                     y = theRow * 8;
-<a class="jxr_linenumber" name="L705" href="#L705">705</a>                 } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="L706" href="#L706">706</a>                     theRow -= rowsInPass1;
-<a class="jxr_linenumber" name="L707" href="#L707">707</a>                     <strong class="jxr_keyword">if</strong> (theRow &lt; (rowsInPass2)) {
-<a class="jxr_linenumber" name="L708" href="#L708">708</a>                         y = 4 + (theRow * 8);
-<a class="jxr_linenumber" name="L709" href="#L709">709</a>                     } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="L710" href="#L710">710</a>                         theRow -= rowsInPass2;
-<a class="jxr_linenumber" name="L711" href="#L711">711</a>                         <strong class="jxr_keyword">if</strong> (theRow &lt; (rowsInPass3)) {
-<a class="jxr_linenumber" name="L712" href="#L712">712</a>                             y = 2 + (theRow * 4);
-<a class="jxr_linenumber" name="L713" href="#L713">713</a>                         } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="L714" href="#L714">714</a>                             theRow -= rowsInPass3;
-<a class="jxr_linenumber" name="L715" href="#L715">715</a>                             <strong class="jxr_keyword">if</strong> (theRow &lt; (rowsInPass4)) {
-<a class="jxr_linenumber" name="L716" href="#L716">716</a>                                 y = 1 + (theRow * 2);
-<a class="jxr_linenumber" name="L717" href="#L717">717</a>                             } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="L718" href="#L718">718</a>                                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"Gif: Strange Row"</span>);
-<a class="jxr_linenumber" name="L719" href="#L719">719</a>                             }
-<a class="jxr_linenumber" name="L720" href="#L720">720</a>                         }
-<a class="jxr_linenumber" name="L721" href="#L721">721</a>                     }
-<a class="jxr_linenumber" name="L722" href="#L722">722</a>                 }
-<a class="jxr_linenumber" name="L723" href="#L723">723</a>             } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="L724" href="#L724">724</a>                 y = row;
-<a class="jxr_linenumber" name="L725" href="#L725">725</a>             }
-<a class="jxr_linenumber" name="L726" href="#L726">726</a> 
-<a class="jxr_linenumber" name="L727" href="#L727">727</a>             <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> x = 0; x &lt; width; x++) {
-<a class="jxr_linenumber" name="L728" href="#L728">728</a>                 <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> index = 0xff &amp; id.imageData[counter++];
-<a class="jxr_linenumber" name="L729" href="#L729">729</a>                 <strong class="jxr_keyword">int</strong> rgb = colorTable[index];
-<a class="jxr_linenumber" name="L730" href="#L730">730</a> 
-<a class="jxr_linenumber" name="L731" href="#L731">731</a>                 <strong class="jxr_keyword">if</strong> (transparentIndex == index) {
-<a class="jxr_linenumber" name="L732" href="#L732">732</a>                     rgb = 0x00;
-<a class="jxr_linenumber" name="L733" href="#L733">733</a>                 }
-<a class="jxr_linenumber" name="L734" href="#L734">734</a> 
-<a class="jxr_linenumber" name="L735" href="#L735">735</a>                 imageBuilder.setRGB(x, y, rgb);
-<a class="jxr_linenumber" name="L736" href="#L736">736</a>             }
-<a class="jxr_linenumber" name="L737" href="#L737">737</a> 
-<a class="jxr_linenumber" name="L738" href="#L738">738</a>         }
-<a class="jxr_linenumber" name="L739" href="#L739">739</a> 
-<a class="jxr_linenumber" name="L740" href="#L740">740</a>         <strong class="jxr_keyword">return</strong> imageBuilder.getBufferedImage();
-<a class="jxr_linenumber" name="L741" href="#L741">741</a> 
-<a class="jxr_linenumber" name="L742" href="#L742">742</a>     }
-<a class="jxr_linenumber" name="L743" href="#L743">743</a> 
-<a class="jxr_linenumber" name="L744" href="#L744">744</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> writeAsSubBlocks(<strong class="jxr_keyword">final</strong> OutputStream os, <strong class="jxr_keyword">final</strong> byte[] bytes) <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="L745" href="#L745">745</a>         <strong class="jxr_keyword">int</strong> index = 0;
-<a class="jxr_linenumber" name="L746" href="#L746">746</a> 
-<a class="jxr_linenumber" name="L747" href="#L747">747</a>         <strong class="jxr_keyword">while</strong> (index &lt; bytes.length) {
-<a class="jxr_linenumber" name="L748" href="#L748">748</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> blockSize = Math.min(bytes.length - index, 255);
-<a class="jxr_linenumber" name="L749" href="#L749">749</a>             os.write(blockSize);
-<a class="jxr_linenumber" name="L750" href="#L750">750</a>             os.write(bytes, index, blockSize);
-<a class="jxr_linenumber" name="L751" href="#L751">751</a>             index += blockSize;
-<a class="jxr_linenumber" name="L752" href="#L752">752</a>         }
-<a class="jxr_linenumber" name="L753" href="#L753">753</a>         os.write(0); <em class="jxr_comment">// last block</em>
-<a class="jxr_linenumber" name="L754" href="#L754">754</a>     }
-<a class="jxr_linenumber" name="L755" href="#L755">755</a> 
-<a class="jxr_linenumber" name="L756" href="#L756">756</a>     @Override
-<a class="jxr_linenumber" name="L757" href="#L757">757</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> writeImage(<strong class="jxr_keyword">final</strong> BufferedImage src, <strong class="jxr_keyword">final</strong> OutputStream os, Map&lt;String, Object&gt; params)
-<a class="jxr_linenumber" name="L758" href="#L758">758</a>             <strong class="jxr_keyword">throws</strong> ImageWriteException, IOException {
-<a class="jxr_linenumber" name="L759" href="#L759">759</a>         <em class="jxr_comment">// make copy of params; we'll clear keys as we consume them.</em>
-<a class="jxr_linenumber" name="L760" href="#L760">760</a>         params = <strong class="jxr_keyword">new</strong> HashMap&lt;String, Object&gt;(params);
-<a class="jxr_linenumber" name="L761" href="#L761">761</a> 
-<a class="jxr_linenumber" name="L762" href="#L762">762</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> verbose =  Boolean.TRUE.equals(params.get(PARAM_KEY_VERBOSE));
-<a class="jxr_linenumber" name="L763" href="#L763">763</a> 
-<a class="jxr_linenumber" name="L764" href="#L764">764</a>         <em class="jxr_comment">// clear format key.</em>
-<a class="jxr_linenumber" name="L765" href="#L765">765</a>         <strong class="jxr_keyword">if</strong> (params.containsKey(PARAM_KEY_FORMAT)) {
-<a class="jxr_linenumber" name="L766" href="#L766">766</a>             params.remove(PARAM_KEY_FORMAT);
-<a class="jxr_linenumber" name="L767" href="#L767">767</a>         }
-<a class="jxr_linenumber" name="L768" href="#L768">768</a>         <strong class="jxr_keyword">if</strong> (params.containsKey(PARAM_KEY_VERBOSE)) {
-<a class="jxr_linenumber" name="L769" href="#L769">769</a>             params.remove(PARAM_KEY_VERBOSE);
-<a class="jxr_linenumber" name="L770" href="#L770">770</a>         }
-<a class="jxr_linenumber" name="L771" href="#L771">771</a> 
-<a class="jxr_linenumber" name="L772" href="#L772">772</a>         String xmpXml = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="L773" href="#L773">773</a>         <strong class="jxr_keyword">if</strong> (params.containsKey(PARAM_KEY_XMP_XML)) {
-<a class="jxr_linenumber" name="L774" href="#L774">774</a>             xmpXml = (String) params.get(PARAM_KEY_XMP_XML);
-<a class="jxr_linenumber" name="L775" href="#L775">775</a>             params.remove(PARAM_KEY_XMP_XML);
-<a class="jxr_linenumber" name="L776" href="#L776">776</a>         }
-<a class="jxr_linenumber" name="L777" href="#L777">777</a> 
-<a class="jxr_linenumber" name="L778" href="#L778">778</a>         <strong class="jxr_keyword">if</strong> (!params.isEmpty()) {
-<a class="jxr_linenumber" name="L779" href="#L779">779</a>             <strong class="jxr_keyword">final</strong> Object firstKey = params.keySet().iterator().next();
-<a class="jxr_linenumber" name="L780" href="#L780">780</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageWriteException.html">ImageWriteException</a>(<span class="jxr_string">"Unknown parameter: "</span> + firstKey);
-<a class="jxr_linenumber" name="L781" href="#L781">781</a>         }
-<a class="jxr_linenumber" name="L782" href="#L782">782</a> 
-<a class="jxr_linenumber" name="L783" href="#L783">783</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> width = src.getWidth();
-<a class="jxr_linenumber" name="L784" href="#L784">784</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> height = src.getHeight();
-<a class="jxr_linenumber" name="L785" href="#L785">785</a> 
-<a class="jxr_linenumber" name="L786" href="#L786">786</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> hasAlpha = <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/palette/PaletteFactory.html">PaletteFactory</a>().hasTransparency(src);
-<a class="jxr_linenumber" name="L787" href="#L787">787</a> 
-<a class="jxr_linenumber" name="L788" href="#L788">788</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> maxColors = hasAlpha ? 255 : 256;
-<a class="jxr_linenumber" name="L789" href="#L789">789</a> 
-<a class="jxr_linenumber" name="L790" href="#L790">790</a>         <a href="../../../../../../org/apache/commons/imaging/palette/Palette.html">Palette</a> palette2 = <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/palette/PaletteFactory.html">PaletteFactory</a>().makeExactRgbPaletteSimple(src, maxColors);
-<a class="jxr_linenumber" name="L791" href="#L791">791</a>         <em class="jxr_comment">// int palette[] = new PaletteFactory().makePaletteSimple(src, 256);</em>
-<a class="jxr_linenumber" name="L792" href="#L792">792</a>         <em class="jxr_comment">// Map palette_map = paletteToMap(palette);</em>
-<a class="jxr_linenumber" name="L793" href="#L793">793</a> 
-<a class="jxr_linenumber" name="L794" href="#L794">794</a>         <strong class="jxr_keyword">if</strong> (palette2 == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L795" href="#L795">795</a>             palette2 = <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/palette/PaletteFactory.html">PaletteFactory</a>().makeQuantizedRgbPalette(src, maxColors);
-<a class="jxr_linenumber" name="L796" href="#L796">796</a>             <strong class="jxr_keyword">if</strong> (verbose) {
-<a class="jxr_linenumber" name="L797" href="#L797">797</a>                 System.out.println(<span class="jxr_string">"quantizing"</span>);
-<a class="jxr_linenumber" name="L798" href="#L798">798</a>             }
-<a class="jxr_linenumber" name="L799" href="#L799">799</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (verbose) {
-<a class="jxr_linenumber" name="L800" href="#L800">800</a>             System.out.println(<span class="jxr_string">"exact palette"</span>);
-<a class="jxr_linenumber" name="L801" href="#L801">801</a>         }
-<a class="jxr_linenumber" name="L802" href="#L802">802</a> 
-<a class="jxr_linenumber" name="L803" href="#L803">803</a>         <strong class="jxr_keyword">if</strong> (palette2 == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L804" href="#L804">804</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageWriteException.html">ImageWriteException</a>(<span class="jxr_string">"Gif: can't write images with more than 256 colors"</span>);
-<a class="jxr_linenumber" name="L805" href="#L805">805</a>         }
-<a class="jxr_linenumber" name="L806" href="#L806">806</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> paletteSize = palette2.length() + (hasAlpha ? 1 : 0);
-<a class="jxr_linenumber" name="L807" href="#L807">807</a> 
-<a class="jxr_linenumber" name="L808" href="#L808">808</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/BinaryOutputStream.html">BinaryOutputStream</a> bos = <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/common/BinaryOutputStream.html">BinaryOutputStream</a>(os, ByteOrder.LITTLE_ENDIAN);
-<a class="jxr_linenumber" name="L809" href="#L809">809</a> 
-<a class="jxr_linenumber" name="L810" href="#L810">810</a>         <em class="jxr_comment">// write Header</em>
-<a class="jxr_linenumber" name="L811" href="#L811">811</a>         os.write(0x47); <em class="jxr_comment">// G magic numbers</em>
-<a class="jxr_linenumber" name="L812" href="#L812">812</a>         os.write(0x49); <em class="jxr_comment">// I</em>
-<a class="jxr_linenumber" name="L813" href="#L813">813</a>         os.write(0x46); <em class="jxr_comment">// F</em>
-<a class="jxr_linenumber" name="L814" href="#L814">814</a> 
-<a class="jxr_linenumber" name="L815" href="#L815">815</a>         os.write(0x38); <em class="jxr_comment">// 8 version magic numbers</em>
-<a class="jxr_linenumber" name="L816" href="#L816">816</a>         os.write(0x39); <em class="jxr_comment">// 9</em>
-<a class="jxr_linenumber" name="L817" href="#L817">817</a>         os.write(0x61); <em class="jxr_comment">// a</em>
-<a class="jxr_linenumber" name="L818" href="#L818">818</a> 
-<a class="jxr_linenumber" name="L819" href="#L819">819</a>         <em class="jxr_comment">// Logical Screen Descriptor.</em>
-<a class="jxr_linenumber" name="L820" href="#L820">820</a> 
-<a class="jxr_linenumber" name="L821" href="#L821">821</a>         bos.write2Bytes(width);
-<a class="jxr_linenumber" name="L822" href="#L822">822</a>         bos.write2Bytes(height);
-<a class="jxr_linenumber" name="L823" href="#L823">823</a> 
-<a class="jxr_linenumber" name="L824" href="#L824">824</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> colorTableScaleLessOne = (paletteSize &gt; 128) ? 7
-<a class="jxr_linenumber" name="L825" href="#L825">825</a>                 : (paletteSize &gt; 64) ? 6 : (paletteSize &gt; 32) ? 5
-<a class="jxr_linenumber" name="L826" href="#L826">826</a>                         : (paletteSize &gt; 16) ? 4 : (paletteSize &gt; 8) ? 3
-<a class="jxr_linenumber" name="L827" href="#L827">827</a>                                 : (paletteSize &gt; 4) ? 2
-<a class="jxr_linenumber" name="L828" href="#L828">828</a>                                         : (paletteSize &gt; 2) ? 1 : 0;
-<a class="jxr_linenumber" name="L829" href="#L829">829</a> 
-<a class="jxr_linenumber" name="L830" href="#L830">830</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> colorTableSizeInFormat = 1 &lt;&lt; (colorTableScaleLessOne + 1);
-<a class="jxr_linenumber" name="L831" href="#L831">831</a>         {
-<a class="jxr_linenumber" name="L832" href="#L832">832</a>             <strong class="jxr_keyword">final</strong> byte colorResolution = (byte) colorTableScaleLessOne; <em class="jxr_comment">// TODO:</em>
-<a class="jxr_linenumber" name="L833" href="#L833">833</a> 
-<a class="jxr_linenumber" name="L834" href="#L834">834</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> globalColorTableFlag = false;
-<a class="jxr_linenumber" name="L835" href="#L835">835</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> sortFlag = false;
-<a class="jxr_linenumber" name="L836" href="#L836">836</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> globalColorTableFlagMask = 1 &lt;&lt; 7;
-<a class="jxr_linenumber" name="L837" href="#L837">837</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> sortFlagMask = 8;
-<a class="jxr_linenumber" name="L838" href="#L838">838</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> sizeOfGlobalColorTable = 0;
-<a class="jxr_linenumber" name="L839" href="#L839">839</a> 
-<a class="jxr_linenumber" name="L840" href="#L840">840</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> packedFields = ((globalColorTableFlag ? globalColorTableFlagMask
-<a class="jxr_linenumber" name="L841" href="#L841">841</a>                     : 0)
-<a class="jxr_linenumber" name="L842" href="#L842">842</a>                     | (sortFlag ? sortFlagMask : 0)
-<a class="jxr_linenumber" name="L843" href="#L843">843</a>                     | ((7 &amp; colorResolution) &lt;&lt; 4) | (7 &amp; sizeOfGlobalColorTable));
-<a class="jxr_linenumber" name="L844" href="#L844">844</a>             bos.write(packedFields); <em class="jxr_comment">// one byte</em>
-<a class="jxr_linenumber" name="L845" href="#L845">845</a>         }
-<a class="jxr_linenumber" name="L846" href="#L846">846</a>         {
-<a class="jxr_linenumber" name="L847" href="#L847">847</a>             <strong class="jxr_keyword">final</strong> byte backgroundColorIndex = 0;
-<a class="jxr_linenumber" name="L848" href="#L848">848</a>             bos.write(backgroundColorIndex);
-<a class="jxr_linenumber" name="L849" href="#L849">849</a>         }
-<a class="jxr_linenumber" name="L850" href="#L850">850</a>         {
-<a class="jxr_linenumber" name="L851" href="#L851">851</a>             <strong class="jxr_keyword">final</strong> byte pixelAspectRatio = 0;
-<a class="jxr_linenumber" name="L852" href="#L852">852</a>             bos.write(pixelAspectRatio);
-<a class="jxr_linenumber" name="L853" href="#L853">853</a>         }
-<a class="jxr_linenumber" name="L854" href="#L854">854</a> 
-<a class="jxr_linenumber" name="L855" href="#L855">855</a>         <em class="jxr_comment">//{</em>
-<a class="jxr_linenumber" name="L856" href="#L856">856</a>             <em class="jxr_comment">// write Global Color Table.</em>
-<a class="jxr_linenumber" name="L857" href="#L857">857</a> 
-<a class="jxr_linenumber" name="L858" href="#L858">858</a>         <em class="jxr_comment">//}</em>
-<a class="jxr_linenumber" name="L859" href="#L859">859</a> 
-<a class="jxr_linenumber" name="L860" href="#L860">860</a>         { <em class="jxr_comment">// ALWAYS write GraphicControlExtension</em>
-<a class="jxr_linenumber" name="L861" href="#L861">861</a>             bos.write(EXTENSION_CODE);
-<a class="jxr_linenumber" name="L862" href="#L862">862</a>             bos.write((byte) 0xf9);
-<a class="jxr_linenumber" name="L863" href="#L863">863</a>             <em class="jxr_comment">// bos.write(0xff &amp; (kGraphicControlExtension &gt;&gt; 8));</em>
-<a class="jxr_linenumber" name="L864" href="#L864">864</a>             <em class="jxr_comment">// bos.write(0xff &amp; (kGraphicControlExtension &gt;&gt; 0));</em>
-<a class="jxr_linenumber" name="L865" href="#L865">865</a> 
-<a class="jxr_linenumber" name="L866" href="#L866">866</a>             bos.write((byte) 4); <em class="jxr_comment">// block size;</em>
-<a class="jxr_linenumber" name="L867" href="#L867">867</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> packedFields = hasAlpha ? 1 : 0; <em class="jxr_comment">// transparency flag</em>
-<a class="jxr_linenumber" name="L868" href="#L868">868</a>             bos.write((byte) packedFields);
-<a class="jxr_linenumber" name="L869" href="#L869">869</a>             bos.write((byte) 0); <em class="jxr_comment">// Delay Time</em>
+<a class="jxr_linenumber" name="L499" href="#L499">499</a>     <em class="jxr_comment">// FIXME should throw UOE</em>
+<a class="jxr_linenumber" name="L500" href="#L500">500</a>     @Override
+<a class="jxr_linenumber" name="L501" href="#L501">501</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../../org/apache/commons/imaging/common/ImageMetadata.html">ImageMetadata</a> getMetadata(<strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/bytesource/ByteSource.html">ByteSource</a> byteSource, <strong class="jxr_keyword">final</strong> Map&lt;String, Object&gt; params)
+<a class="jxr_linenumber" name="L502" href="#L502">502</a>             <strong class="jxr_keyword">throws</strong> ImageReadException, IOException {
+<a class="jxr_linenumber" name="L503" href="#L503">503</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a class="jxr_linenumber" name="L504" href="#L504">504</a>     }
+<a class="jxr_linenumber" name="L505" href="#L505">505</a> 
+<a class="jxr_linenumber" name="L506" href="#L506">506</a>     <strong class="jxr_keyword">private</strong> List&lt;String&gt; getComments(<strong class="jxr_keyword">final</strong> List&lt;GifBlock&gt; blocks) <strong class="jxr_keyword">throws</strong> IOException {
+<a class="jxr_linenumber" name="L507" href="#L507">507</a>         <strong class="jxr_keyword">final</strong> List&lt;String&gt; result = <strong class="jxr_keyword">new</strong> ArrayList&lt;String&gt;();
+<a class="jxr_linenumber" name="L508" href="#L508">508</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> code = 0x21fe;
+<a class="jxr_linenumber" name="L509" href="#L509">509</a> 
+<a class="jxr_linenumber" name="L510" href="#L510">510</a>         <strong class="jxr_keyword">for</strong> (GifBlock block : blocks) {
+<a class="jxr_linenumber" name="L511" href="#L511">511</a>             <strong class="jxr_keyword">if</strong> (block.blockCode == code) {
+<a class="jxr_linenumber" name="L512" href="#L512">512</a>                 <strong class="jxr_keyword">final</strong> byte[] bytes = ((GenericGifBlock) block).appendSubBlocks();
+<a class="jxr_linenumber" name="L513" href="#L513">513</a>                 result.add(<strong class="jxr_keyword">new</strong> String(bytes, <span class="jxr_string">"US-ASCII"</span>));
+<a class="jxr_linenumber" name="L514" href="#L514">514</a>             }
+<a class="jxr_linenumber" name="L515" href="#L515">515</a>         }
+<a class="jxr_linenumber" name="L516" href="#L516">516</a> 
+<a class="jxr_linenumber" name="L517" href="#L517">517</a>         <strong class="jxr_keyword">return</strong> result;
+<a class="jxr_linenumber" name="L518" href="#L518">518</a>     }
+<a class="jxr_linenumber" name="L519" href="#L519">519</a> 
+<a class="jxr_linenumber" name="L520" href="#L520">520</a>     @Override
+<a class="jxr_linenumber" name="L521" href="#L521">521</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../../org/apache/commons/imaging/ImageInfo.html">ImageInfo</a> getImageInfo(<strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/bytesource/ByteSource.html">ByteSource</a> byteSource, <strong class="jxr_keyword">final</strong> Map&lt;String, Object&gt; params)
+<a class="jxr_linenumber" name="L522" href="#L522">522</a>             <strong class="jxr_keyword">throws</strong> ImageReadException, IOException {
+<a class="jxr_linenumber" name="L523" href="#L523">523</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/ImageContents.html">ImageContents</a> blocks = readFile(byteSource, false);
+<a class="jxr_linenumber" name="L524" href="#L524">524</a> 
+<a class="jxr_linenumber" name="L525" href="#L525">525</a>         <strong class="jxr_keyword">if</strong> (blocks == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L526" href="#L526">526</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read blocks"</span>);
+<a class="jxr_linenumber" name="L527" href="#L527">527</a>         }
+<a class="jxr_linenumber" name="L528" href="#L528">528</a> 
+<a class="jxr_linenumber" name="L529" href="#L529">529</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/GifHeaderInfo.html">GifHeaderInfo</a> bhi = blocks.gifHeaderInfo;
+<a class="jxr_linenumber" name="L530" href="#L530">530</a>         <strong class="jxr_keyword">if</strong> (bhi == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L531" href="#L531">531</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read Header"</span>);
+<a class="jxr_linenumber" name="L532" href="#L532">532</a>         }
+<a class="jxr_linenumber" name="L533" href="#L533">533</a> 
+<a class="jxr_linenumber" name="L534" href="#L534">534</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/ImageDescriptor.html">ImageDescriptor</a> id = (ImageDescriptor) findBlock(blocks.blocks,
+<a class="jxr_linenumber" name="L535" href="#L535">535</a>                 IMAGE_SEPARATOR);
+<a class="jxr_linenumber" name="L536" href="#L536">536</a>         <strong class="jxr_keyword">if</strong> (id == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L537" href="#L537">537</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read ImageDescriptor"</span>);
+<a class="jxr_linenumber" name="L538" href="#L538">538</a>         }
+<a class="jxr_linenumber" name="L539" href="#L539">539</a> 
+<a class="jxr_linenumber" name="L540" href="#L540">540</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/GraphicControlExtension.html">GraphicControlExtension</a> gce = (GraphicControlExtension) findBlock(
+<a class="jxr_linenumber" name="L541" href="#L541">541</a>                 blocks.blocks, GRAPHIC_CONTROL_EXTENSION);
+<a class="jxr_linenumber" name="L542" href="#L542">542</a> 
+<a class="jxr_linenumber" name="L543" href="#L543">543</a>         <em class="jxr_comment">// Prefer the size information in the ImageDescriptor; it is more</em>
+<a class="jxr_linenumber" name="L544" href="#L544">544</a>         <em class="jxr_comment">// reliable than the size information in the header.</em>
+<a class="jxr_linenumber" name="L545" href="#L545">545</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> height = id.imageHeight;
+<a class="jxr_linenumber" name="L546" href="#L546">546</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> width = id.imageWidth;
+<a class="jxr_linenumber" name="L547" href="#L547">547</a> 
+<a class="jxr_linenumber" name="L548" href="#L548">548</a>         <strong class="jxr_keyword">final</strong> List&lt;String&gt; comments = getComments(blocks.blocks);
+<a class="jxr_linenumber" name="L549" href="#L549">549</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> bitsPerPixel = (bhi.colorResolution + 1);
+<a class="jxr_linenumber" name="L550" href="#L550">550</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/ImageFormat.html">ImageFormat</a> format = ImageFormats.GIF;
+<a class="jxr_linenumber" name="L551" href="#L551">551</a>         <strong class="jxr_keyword">final</strong> String formatName = <span class="jxr_string">"GIF Graphics Interchange Format"</span>;
+<a class="jxr_linenumber" name="L552" href="#L552">552</a>         <strong class="jxr_keyword">final</strong> String mimeType = <span class="jxr_string">"image/gif"</span>;
+<a class="jxr_linenumber" name="L553" href="#L553">553</a>         <em class="jxr_comment">// we ought to count images, but don't yet.</em>
+<a class="jxr_linenumber" name="L554" href="#L554">554</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> numberOfImages = -1;
+<a class="jxr_linenumber" name="L555" href="#L555">555</a> 
+<a class="jxr_linenumber" name="L556" href="#L556">556</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> progressive = id.interlaceFlag;
+<a class="jxr_linenumber" name="L557" href="#L557">557</a> 
+<a class="jxr_linenumber" name="L558" href="#L558">558</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> physicalWidthDpi = 72;
+<a class="jxr_linenumber" name="L559" href="#L559">559</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">float</strong> physicalWidthInch = (<strong class="jxr_keyword">float</strong>) ((<strong class="jxr_keyword">double</strong>) width / (<strong class="jxr_keyword">double</strong>) physicalWidthDpi);
+<a class="jxr_linenumber" name="L560" href="#L560">560</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> physicalHeightDpi = 72;
+<a class="jxr_linenumber" name="L561" href="#L561">561</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">float</strong> physicalHeightInch = (<strong class="jxr_keyword">float</strong>) ((<strong class="jxr_keyword">double</strong>) height / (<strong class="jxr_keyword">double</strong>) physicalHeightDpi);
+<a class="jxr_linenumber" name="L562" href="#L562">562</a> 
+<a class="jxr_linenumber" name="L563" href="#L563">563</a>         <strong class="jxr_keyword">final</strong> String formatDetails = <span class="jxr_string">"Gif "</span> + ((<strong class="jxr_keyword">char</strong>) blocks.gifHeaderInfo.version1)
+<a class="jxr_linenumber" name="L564" href="#L564">564</a>                 + ((<strong class="jxr_keyword">char</strong>) blocks.gifHeaderInfo.version2)
+<a class="jxr_linenumber" name="L565" href="#L565">565</a>                 + ((<strong class="jxr_keyword">char</strong>) blocks.gifHeaderInfo.version3);
+<a class="jxr_linenumber" name="L566" href="#L566">566</a> 
+<a class="jxr_linenumber" name="L567" href="#L567">567</a>         <strong class="jxr_keyword">boolean</strong> transparent = false;
+<a class="jxr_linenumber" name="L568" href="#L568">568</a>         <strong class="jxr_keyword">if</strong> (gce != <strong class="jxr_keyword">null</strong> &amp;&amp; gce.transparency) {
+<a class="jxr_linenumber" name="L569" href="#L569">569</a>             transparent = <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="L570" href="#L570">570</a>         }
+<a class="jxr_linenumber" name="L571" href="#L571">571</a> 
+<a class="jxr_linenumber" name="L572" href="#L572">572</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> usesPalette = <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="L573" href="#L573">573</a>         <strong class="jxr_keyword">final</strong> ImageInfo.ColorType colorType = ImageInfo.ColorType.RGB;
+<a class="jxr_linenumber" name="L574" href="#L574">574</a>         <strong class="jxr_keyword">final</strong> ImageInfo.CompressionAlgorithm compressionAlgorithm = ImageInfo.CompressionAlgorithm.LZW;
+<a class="jxr_linenumber" name="L575" href="#L575">575</a> 
+<a class="jxr_linenumber" name="L576" href="#L576">576</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageInfo.html">ImageInfo</a>(formatDetails, bitsPerPixel, comments,
+<a class="jxr_linenumber" name="L577" href="#L577">577</a>                 format, formatName, height, mimeType, numberOfImages,
+<a class="jxr_linenumber" name="L578" href="#L578">578</a>                 physicalHeightDpi, physicalHeightInch, physicalWidthDpi,
+<a class="jxr_linenumber" name="L579" href="#L579">579</a>                 physicalWidthInch, width, progressive, transparent,
+<a class="jxr_linenumber" name="L580" href="#L580">580</a>                 usesPalette, colorType, compressionAlgorithm);
+<a class="jxr_linenumber" name="L581" href="#L581">581</a>     }
+<a class="jxr_linenumber" name="L582" href="#L582">582</a> 
+<a class="jxr_linenumber" name="L583" href="#L583">583</a>     @Override
+<a class="jxr_linenumber" name="L584" href="#L584">584</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> dumpImageFile(<strong class="jxr_keyword">final</strong> PrintWriter pw, <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/bytesource/ByteSource.html">ByteSource</a> byteSource)
+<a class="jxr_linenumber" name="L585" href="#L585">585</a>             <strong class="jxr_keyword">throws</strong> ImageReadException, IOException {
+<a class="jxr_linenumber" name="L586" href="#L586">586</a>         pw.println(<span class="jxr_string">"gif.dumpImageFile"</span>);
+<a class="jxr_linenumber" name="L587" href="#L587">587</a> 
+<a class="jxr_linenumber" name="L588" href="#L588">588</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/ImageInfo.html">ImageInfo</a> imageData = getImageInfo(byteSource);
+<a class="jxr_linenumber" name="L589" href="#L589">589</a>         <strong class="jxr_keyword">if</strong> (imageData == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L590" href="#L590">590</a>             <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L591" href="#L591">591</a>         }
+<a class="jxr_linenumber" name="L592" href="#L592">592</a> 
+<a class="jxr_linenumber" name="L593" href="#L593">593</a>         imageData.toString(pw, <span class="jxr_string">""</span>);
+<a class="jxr_linenumber" name="L594" href="#L594">594</a>         
+<a class="jxr_linenumber" name="L595" href="#L595">595</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/ImageContents.html">ImageContents</a> blocks = readFile(byteSource, false);
+<a class="jxr_linenumber" name="L596" href="#L596">596</a> 
+<a class="jxr_linenumber" name="L597" href="#L597">597</a>         pw.println(<span class="jxr_string">"gif.blocks: "</span> + blocks.blocks.size());
+<a class="jxr_linenumber" name="L598" href="#L598">598</a>         <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; blocks.blocks.size(); i++) {
+<a class="jxr_linenumber" name="L599" href="#L599">599</a>             <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/GifBlock.html">GifBlock</a> gifBlock = blocks.blocks.get(i);
+<a class="jxr_linenumber" name="L600" href="#L600">600</a>             <strong class="jxr_keyword">this</strong>.debugNumber(pw, <span class="jxr_string">"\t"</span> + i + <span class="jxr_string">" ("</span>
+<a class="jxr_linenumber" name="L601" href="#L601">601</a>                     + gifBlock.getClass().getName() + <span class="jxr_string">")"</span>,
+<a class="jxr_linenumber" name="L602" href="#L602">602</a>                     gifBlock.blockCode, 4);
+<a class="jxr_linenumber" name="L603" href="#L603">603</a>         }
+<a class="jxr_linenumber" name="L604" href="#L604">604</a> 
+<a class="jxr_linenumber" name="L605" href="#L605">605</a>         pw.println(<span class="jxr_string">""</span>);
+<a class="jxr_linenumber" name="L606" href="#L606">606</a> 
+<a class="jxr_linenumber" name="L607" href="#L607">607</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="L608" href="#L608">608</a>     }
+<a class="jxr_linenumber" name="L609" href="#L609">609</a> 
+<a class="jxr_linenumber" name="L610" href="#L610">610</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong>[] getColorTable(<strong class="jxr_keyword">final</strong> byte[] bytes) <strong class="jxr_keyword">throws</strong> ImageReadException {
+<a class="jxr_linenumber" name="L611" href="#L611">611</a>         <strong class="jxr_keyword">if</strong> ((bytes.length % 3) != 0) {
+<a class="jxr_linenumber" name="L612" href="#L612">612</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"Bad Color Table Length: "</span>
+<a class="jxr_linenumber" name="L613" href="#L613">613</a>                     + bytes.length);
+<a class="jxr_linenumber" name="L614" href="#L614">614</a>         }
+<a class="jxr_linenumber" name="L615" href="#L615">615</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> length = bytes.length / 3;
+<a class="jxr_linenumber" name="L616" href="#L616">616</a> 
+<a class="jxr_linenumber" name="L617" href="#L617">617</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong>[] result = <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[length];
+<a class="jxr_linenumber" name="L618" href="#L618">618</a> 
+<a class="jxr_linenumber" name="L619" href="#L619">619</a>         <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; length; i++) {
+<a class="jxr_linenumber" name="L620" href="#L620">620</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> red = 0xff &amp; bytes[(i * 3) + 0];
+<a class="jxr_linenumber" name="L621" href="#L621">621</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> green = 0xff &amp; bytes[(i * 3) + 1];
+<a class="jxr_linenumber" name="L622" href="#L622">622</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> blue = 0xff &amp; bytes[(i * 3) + 2];
+<a class="jxr_linenumber" name="L623" href="#L623">623</a> 
+<a class="jxr_linenumber" name="L624" href="#L624">624</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> alpha = 0xff;
+<a class="jxr_linenumber" name="L625" href="#L625">625</a> 
+<a class="jxr_linenumber" name="L626" href="#L626">626</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> rgb = (alpha &lt;&lt; 24) | (red &lt;&lt; 16) | (green &lt;&lt; 8) | (blue &lt;&lt; 0);
+<a class="jxr_linenumber" name="L627" href="#L627">627</a>             result[i] = rgb;
+<a class="jxr_linenumber" name="L628" href="#L628">628</a>         }
+<a class="jxr_linenumber" name="L629" href="#L629">629</a> 
+<a class="jxr_linenumber" name="L630" href="#L630">630</a>         <strong class="jxr_keyword">return</strong> result;
+<a class="jxr_linenumber" name="L631" href="#L631">631</a>     }
+<a class="jxr_linenumber" name="L632" href="#L632">632</a> 
+<a class="jxr_linenumber" name="L633" href="#L633">633</a>     @Override
+<a class="jxr_linenumber" name="L634" href="#L634">634</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../../org/apache/commons/imaging/FormatCompliance.html">FormatCompliance</a> getFormatCompliance(<strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/bytesource/ByteSource.html">ByteSource</a> byteSource)
+<a class="jxr_linenumber" name="L635" href="#L635">635</a>             <strong class="jxr_keyword">throws</strong> ImageReadException, IOException {
+<a class="jxr_linenumber" name="L636" href="#L636">636</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/FormatCompliance.html">FormatCompliance</a> result = <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/FormatCompliance.html">FormatCompliance</a>(
+<a class="jxr_linenumber" name="L637" href="#L637">637</a>                 byteSource.getDescription());
+<a class="jxr_linenumber" name="L638" href="#L638">638</a> 
+<a class="jxr_linenumber" name="L639" href="#L639">639</a>         readFile(byteSource, false, result);
+<a class="jxr_linenumber" name="L640" href="#L640">640</a> 
+<a class="jxr_linenumber" name="L641" href="#L641">641</a>         <strong class="jxr_keyword">return</strong> result;
+<a class="jxr_linenumber" name="L642" href="#L642">642</a>     }
+<a class="jxr_linenumber" name="L643" href="#L643">643</a> 
+<a class="jxr_linenumber" name="L644" href="#L644">644</a>     @Override
+<a class="jxr_linenumber" name="L645" href="#L645">645</a>     <strong class="jxr_keyword">public</strong> BufferedImage getBufferedImage(<strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/bytesource/ByteSource.html">ByteSource</a> byteSource, <strong class="jxr_keyword">final</strong> Map&lt;String, Object&gt; params)
+<a class="jxr_linenumber" name="L646" href="#L646">646</a>             <strong class="jxr_keyword">throws</strong> ImageReadException, IOException {
+<a class="jxr_linenumber" name="L647" href="#L647">647</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/ImageContents.html">ImageContents</a> imageContents = readFile(byteSource, false);
+<a class="jxr_linenumber" name="L648" href="#L648">648</a> 
+<a class="jxr_linenumber" name="L649" href="#L649">649</a>         <strong class="jxr_keyword">if</strong> (imageContents == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L650" href="#L650">650</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read blocks"</span>);
+<a class="jxr_linenumber" name="L651" href="#L651">651</a>         }
+<a class="jxr_linenumber" name="L652" href="#L652">652</a> 
+<a class="jxr_linenumber" name="L653" href="#L653">653</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/GifHeaderInfo.html">GifHeaderInfo</a> ghi = imageContents.gifHeaderInfo;
+<a class="jxr_linenumber" name="L654" href="#L654">654</a>         <strong class="jxr_keyword">if</strong> (ghi == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L655" href="#L655">655</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read Header"</span>);
+<a class="jxr_linenumber" name="L656" href="#L656">656</a>         }
+<a class="jxr_linenumber" name="L657" href="#L657">657</a> 
+<a class="jxr_linenumber" name="L658" href="#L658">658</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/ImageDescriptor.html">ImageDescriptor</a> id = (ImageDescriptor) findBlock(imageContents.blocks,
+<a class="jxr_linenumber" name="L659" href="#L659">659</a>                 IMAGE_SEPARATOR);
+<a class="jxr_linenumber" name="L660" href="#L660">660</a>         <strong class="jxr_keyword">if</strong> (id == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L661" href="#L661">661</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"GIF: Couldn't read Image Descriptor"</span>);
+<a class="jxr_linenumber" name="L662" href="#L662">662</a>         }
+<a class="jxr_linenumber" name="L663" href="#L663">663</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/formats/gif/GraphicControlExtension.html">GraphicControlExtension</a> gce = (GraphicControlExtension) findBlock(
+<a class="jxr_linenumber" name="L664" href="#L664">664</a>                 imageContents.blocks, GRAPHIC_CONTROL_EXTENSION);
+<a class="jxr_linenumber" name="L665" href="#L665">665</a> 
+<a class="jxr_linenumber" name="L666" href="#L666">666</a>         <em class="jxr_comment">// Prefer the size information in the ImageDescriptor; it is more</em>
+<a class="jxr_linenumber" name="L667" href="#L667">667</a>         <em class="jxr_comment">// reliable</em>
+<a class="jxr_linenumber" name="L668" href="#L668">668</a>         <em class="jxr_comment">// than the size information in the header.</em>
+<a class="jxr_linenumber" name="L669" href="#L669">669</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> width = id.imageWidth;
+<a class="jxr_linenumber" name="L670" href="#L670">670</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> height = id.imageHeight;
+<a class="jxr_linenumber" name="L671" href="#L671">671</a> 
+<a class="jxr_linenumber" name="L672" href="#L672">672</a>         <strong class="jxr_keyword">boolean</strong> hasAlpha = false;
+<a class="jxr_linenumber" name="L673" href="#L673">673</a>         <strong class="jxr_keyword">if</strong> (gce != <strong class="jxr_keyword">null</strong> &amp;&amp; gce.transparency) {
+<a class="jxr_linenumber" name="L674" href="#L674">674</a>             hasAlpha = <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="L675" href="#L675">675</a>         }
+<a class="jxr_linenumber" name="L676" href="#L676">676</a> 
+<a class="jxr_linenumber" name="L677" href="#L677">677</a>         <strong class="jxr_keyword">final</strong> <a href="../../../../../../org/apache/commons/imaging/common/ImageBuilder.html">ImageBuilder</a> imageBuilder = <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/common/ImageBuilder.html">ImageBuilder</a>(width, height, hasAlpha);
+<a class="jxr_linenumber" name="L678" href="#L678">678</a> 
+<a class="jxr_linenumber" name="L679" href="#L679">679</a>         <strong class="jxr_keyword">int</strong>[] colorTable;
+<a class="jxr_linenumber" name="L680" href="#L680">680</a>         <strong class="jxr_keyword">if</strong> (id.localColorTable != <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L681" href="#L681">681</a>             colorTable = getColorTable(id.localColorTable);
+<a class="jxr_linenumber" name="L682" href="#L682">682</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (imageContents.globalColorTable != <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L683" href="#L683">683</a>             colorTable = getColorTable(imageContents.globalColorTable);
+<a class="jxr_linenumber" name="L684" href="#L684">684</a>         } <strong class="jxr_keyword">else</strong> {
+<a class="jxr_linenumber" name="L685" href="#L685">685</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"Gif: No Color Table"</span>);
+<a class="jxr_linenumber" name="L686" href="#L686">686</a>         }
+<a class="jxr_linenumber" name="L687" href="#L687">687</a> 
+<a class="jxr_linenumber" name="L688" href="#L688">688</a>         <strong class="jxr_keyword">int</strong> transparentIndex = -1;
+<a class="jxr_linenumber" name="L689" href="#L689">689</a>         <strong class="jxr_keyword">if</strong> (gce != <strong class="jxr_keyword">null</strong> &amp;&amp; hasAlpha) {
+<a class="jxr_linenumber" name="L690" href="#L690">690</a>             transparentIndex = gce.transparentColorIndex;
+<a class="jxr_linenumber" name="L691" href="#L691">691</a>         }
+<a class="jxr_linenumber" name="L692" href="#L692">692</a> 
+<a class="jxr_linenumber" name="L693" href="#L693">693</a>         <strong class="jxr_keyword">int</strong> counter = 0;
+<a class="jxr_linenumber" name="L694" href="#L694">694</a> 
+<a class="jxr_linenumber" name="L695" href="#L695">695</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> rowsInPass1 = (height + 7) / 8;
+<a class="jxr_linenumber" name="L696" href="#L696">696</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> rowsInPass2 = (height + 3) / 8;
+<a class="jxr_linenumber" name="L697" href="#L697">697</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> rowsInPass3 = (height + 1) / 4;
+<a class="jxr_linenumber" name="L698" href="#L698">698</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> rowsInPass4 = (height) / 2;
+<a class="jxr_linenumber" name="L699" href="#L699">699</a> 
+<a class="jxr_linenumber" name="L700" href="#L700">700</a>         <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> row = 0; row &lt; height; row++) {
+<a class="jxr_linenumber" name="L701" href="#L701">701</a>             <strong class="jxr_keyword">int</strong> y;
+<a class="jxr_linenumber" name="L702" href="#L702">702</a>             <strong class="jxr_keyword">if</strong> (id.interlaceFlag) {
+<a class="jxr_linenumber" name="L703" href="#L703">703</a>                 <strong class="jxr_keyword">int</strong> theRow = row;
+<a class="jxr_linenumber" name="L704" href="#L704">704</a>                 <strong class="jxr_keyword">if</strong> (theRow &lt; rowsInPass1) {
+<a class="jxr_linenumber" name="L705" href="#L705">705</a>                     y = theRow * 8;
+<a class="jxr_linenumber" name="L706" href="#L706">706</a>                 } <strong class="jxr_keyword">else</strong> {
+<a class="jxr_linenumber" name="L707" href="#L707">707</a>                     theRow -= rowsInPass1;
+<a class="jxr_linenumber" name="L708" href="#L708">708</a>                     <strong class="jxr_keyword">if</strong> (theRow &lt; (rowsInPass2)) {
+<a class="jxr_linenumber" name="L709" href="#L709">709</a>                         y = 4 + (theRow * 8);
+<a class="jxr_linenumber" name="L710" href="#L710">710</a>                     } <strong class="jxr_keyword">else</strong> {
+<a class="jxr_linenumber" name="L711" href="#L711">711</a>                         theRow -= rowsInPass2;
+<a class="jxr_linenumber" name="L712" href="#L712">712</a>                         <strong class="jxr_keyword">if</strong> (theRow &lt; (rowsInPass3)) {
+<a class="jxr_linenumber" name="L713" href="#L713">713</a>                             y = 2 + (theRow * 4);
+<a class="jxr_linenumber" name="L714" href="#L714">714</a>                         } <strong class="jxr_keyword">else</strong> {
+<a class="jxr_linenumber" name="L715" href="#L715">715</a>                             theRow -= rowsInPass3;
+<a class="jxr_linenumber" name="L716" href="#L716">716</a>                             <strong class="jxr_keyword">if</strong> (theRow &lt; (rowsInPass4)) {
+<a class="jxr_linenumber" name="L717" href="#L717">717</a>                                 y = 1 + (theRow * 2);
+<a class="jxr_linenumber" name="L718" href="#L718">718</a>                             } <strong class="jxr_keyword">else</strong> {
+<a class="jxr_linenumber" name="L719" href="#L719">719</a>                                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/commons/imaging/ImageReadException.html">ImageReadException</a>(<span class="jxr_string">"Gif: Strange Row"</span>);
+<a class="jxr_linenumber" name="L720" href="#L720">720</a>                             }
+<a class="jxr_linenumber" name="L721" href="#L721">721</a>                         }
+<a class="jxr_linenumber" name="L722" href="#L722">722</a>                     }
+<a class="jxr_linenumber" name="L723" href="#L723">723</a>                 }
+<a class="jxr_linenumber" name="L724" href="#L724">724</a>             } <strong class="jxr_keyword">else</strong> {
+<a class="jxr_linenumber" name="L725" href="#L725">725</a>                 y = row;
+<a class="jxr_linenumber" name="L726" href="#L726">726</a>             }
+<a class="jxr_linenumber" name="L727" href="#L727">727</a> 
+<a class="jxr_linenumber" name="L728" href="#L728">728</a>             <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> x = 0; x &lt; width; x++) {
+<a class="jxr_linenumber" name="L729" href="#L729">729</a>                 <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> index = 0xff &amp; id.imageData[counter++];
+<a class="jxr_linenumber" name="L730" href="#L730">730</a>                 <strong class="jxr_keyword">int</strong> rgb = colorTable[index];
+<a class="jxr_linenumber" name="L731" href="#L731">731</a> 
+<a class="jxr_linenumber" name="L732" href="#L732">732</a>                 <strong class="jxr_keyword">if</strong> (transparentIndex == index) {
+<a class="jxr_linenumber" name="L733" href="#L733">733</a>                     rgb = 0x00;
+<a class="jxr_linenumber" name="L734" href="#L734">734</a>                 }
+<a class="jxr_linenumber" name="L735" href="#L735">735</a> 
+<a class="jxr_linenumber" name="L736" href="#L736">736</a>                 imageBuilder.setRGB(x, y, rgb);
+<a class="jxr_linenumber" name="L737" href="#L737">737</a>             }
+<a class="jxr_linenumber" name="L738" href="#L738">738</a> 
+<a class="jxr_linenumber" name="L739" href="#L739">739</a>         }
+<a class="jxr_linenumber" name="L740" href="#L740">740</a> 
+<a class="jxr_linenumber" name="L741" href="#L741">741</a>         <strong class="jxr_keyword">return</strong> imageBuilder.getBufferedImage();
+<a class="jxr_linenumber" name="L742" href="#L742">742</a> 
+<a class="jxr_linenumber" name="L743" href="#L743">743</a>     }
+<a class="jxr_linenumber" name="L744" href="#L744">744</a> 
+<a class="jxr_linenumber" name="L745" href="#L745">745</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> writeAsSubBlocks(<strong class="jxr_keyword">final</strong> OutputStream os, <strong class="jxr_keyword">final</strong> byte[] bytes) <strong class="jxr_keyword">throws</strong> IOException {
+<a class="jxr_linenumber" name="L746" href="#L746">746</a>         <strong class="jxr_keyword">int</strong> index = 0;
+<a class="jxr_linenumber" name="L747" href="#L747">747</a> 
+<a class="jxr_linenumber" name="L748" href="#L748">748</a>         <strong class="jxr_keyword">while</strong> (index &lt; bytes.length) {
+<a class="jxr_linenumber" name="L749" href="#L749">749</a>             <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> blockSize = Math.min(bytes.length - index, 255);
+<a class="jxr_linenumber" name="L750" href="#L750">750</a>             os.write(blockSize);
+<a class="jxr_linenumber" name="L751" href="#L751">751</a>             os.write(bytes, index, blockSize);
+<a class="jxr_linenumber" name="L752" href="#L752">752</a>             index += blockSize;
+<a class="jxr_linenumber" name="L753" href="#L753">753</a>         }
+<a class="jxr_linenumber" name="L754" href="#L754">754</a>         os.write(0); <em class="jxr_comment">// last block</em>
+<a class="jxr_linenumber" name="L755" href="#L755">755</a>     }
+<a class="jxr_linenumber" name="L756" href="#L756">756</a> 
+<a class="jxr_linenumber" name="L757" href="#L757">757</a>     @Override
+<a class="jxr_linenumber" name="L758" href="#L758">758</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> writeImage(<strong class="jxr_keyword">final</strong> BufferedImage src, <strong class="jxr_keyword">final</strong> OutputStream os, Map&lt;String, Object&gt; params)
+<a class="jxr_linenumber" name="L759" href="#L759">759</a>             <strong class="jxr_keyword">throws</strong> ImageWriteException, IOException {
+<a class="jxr_linenumber" name="L760" href="#L760">760</a>         <em class="jxr_comment">// make copy of params; we'll clear keys as we consume them.</em>
+<a class="jxr_linenumber" name="L761" href="#L761">761</a>         params = <strong class="jxr_keyword">new</strong> HashMap&lt;String, Object&gt;(params);
+<a class="jxr_linenumber" name="L762" href="#L762">762</a> 
+<a class="jxr_linenumber" name="L763" href="#L763">763</a>         <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> verbose =  Boolean.TRUE.equals(params.get(PARAM_KEY_VERBOSE));
+<a class="jxr_linenumber" name="L764" href="#L764">764</a> 
+<a class="jxr_linenumber" name="L765" href="#L765">765</a>         <em class="jxr_comment">// clear format key.</em>
+<a class="jxr_linenumber" name="L766" href="#L766">766</a>         <strong class="jxr_keyword">if</strong> (params.containsKey(PARAM_KEY_FORMAT)) {

[... 555 lines stripped ...]


Mime
View raw message