diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-08-21 16:44:00 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-08-21 16:44:00 +0000 |
commit | b5fe4766be47aa3394b7d8d98422c983b246a73c (patch) | |
tree | c6643113fd815d1566ea9db6e9354f4ce27b5597 /src/java/org/apache/fop/image/GifImage.java | |
parent | f5b4eeff769eafa0f2020d4766d25afc675f6142 (diff) | |
download | xmlgraphics-fop-b5fe4766be47aa3394b7d8d98422c983b246a73c.tar.gz xmlgraphics-fop-b5fe4766be47aa3394b7d8d98422c983b246a73c.zip |
Bugzilla #36224:
This patch ports the 0.20.5 CCITTFaxDecode filter functionality and its support
of direct embedding on certain TIFF images to the trunk.
It also cleans up some of the image handling with respect to consistent closing
of the input stream to avoid dangling open files.
Submitted by: Manuel Mall <mm.at.arcus.com.au>
Changes to the patch:
Fixed a small problem with the NullFilter in the PDF library.
Used tiff_group4.tiff in external-graphic-tiff.xml.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@234261 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/image/GifImage.java')
-rw-r--r-- | src/java/org/apache/fop/image/GifImage.java | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/java/org/apache/fop/image/GifImage.java b/src/java/org/apache/fop/image/GifImage.java index 5cb95747c..3cafef559 100644 --- a/src/java/org/apache/fop/image/GifImage.java +++ b/src/java/org/apache/fop/image/GifImage.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import java.net.URLConnection; * @see FopImage */ public class GifImage extends AbstractFopImage { + /** * Create a new gif image. * @@ -52,7 +53,6 @@ public class GifImage extends AbstractFopImage { * To decode the image a dummy URLConnection is used that * will do the conversion. * - * @param ua the user agent for loading * @return True if the load process succeeded */ protected boolean loadBitmap() { @@ -83,9 +83,6 @@ public class GifImage extends AbstractFopImage { return false; } - inputStream.close(); - inputStream = null; - ColorModel cm = consumer.getColorModel(); this.bitsPerPixel = 8; // this.bitsPerPixel = cm.getPixelSize(); @@ -143,11 +140,15 @@ public class GifImage extends AbstractFopImage { this.isTransparent = false; } } catch (Exception ex) { - log.error("Error while loading image " - + "" + " : " - + ex.getClass() + " - " - + ex.getMessage(), ex); + log.error("Error while loading image (Gif): " + ex.getMessage(), ex); return false; + } finally { + try { + inputStream.close(); + } catch (java.io.IOException ioe) { + // Ignore + } + inputStream = null; } // Should take care of the ColorSpace and bitsPerPixel @@ -159,12 +160,9 @@ public class GifImage extends AbstractFopImage { int r = (p >> 16) & 0xFF; int g = (p >> 8) & 0xFF; int b = (p) & 0xFF; - this.bitmaps[3 * (i * this.width + j)] = - (byte)(r & 0xFF); - this.bitmaps[3 * (i * this.width + j) + 1] = - (byte)(g & 0xFF); - this.bitmaps[3 * (i * this.width + j) + 2] = - (byte)(b & 0xFF); + this.bitmaps[3 * (i * this.width + j)] = (byte)(r & 0xFF); + this.bitmaps[3 * (i * this.width + j) + 1] = (byte)(g & 0xFF); + this.bitmaps[3 * (i * this.width + j) + 2] = (byte)(b & 0xFF); } } return true; @@ -181,18 +179,30 @@ public class GifImage extends AbstractFopImage { inputStream = is; } + /** + * @see java.net.URLConnection#getInputStream() + */ public InputStream getInputStream() throws IOException { return inputStream; } + /** + * @see java.net.URLConnection#connect() + */ public void connect() throws IOException { // do nothing } + /** + * @see java.net.URLConnection#getContentType() + */ public String getContentType() { return "image/gif"; } + /** + * @see java.net.URLConnection#getContentLength() + */ public int getContentLength() { try { return inputStream.available(); |