return true;
}
+ /** @see org.apache.fop.image.AbstractFopImage#loadOriginalData() */
+ protected boolean loadOriginalData() {
+ return loadDefaultOriginalData();
+ }
+
}
import java.io.InputStream;
import java.awt.Color;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
return false;
}
+ /**
+ * Load the original image data. This is generic code for use by any
+ * subclass that wants to use this from a loadOriginalData() implementation.
+ *
+ * @return true if the loading was successful
+ */
+ protected boolean loadDefaultOriginalData() {
+ try {
+ this.raw = IOUtils.toByteArray(inputStream);
+ } catch (java.io.IOException ex) {
+ log.error("Error while loading image (EMF): " + ex.getMessage(), ex);
+ return false;
+ } finally {
+ IOUtils.closeQuietly(inputStream);
+ inputStream = null;
+ }
+ return true;
+ }
+
/**
* @return the image width (in pixels)
*/
* @return true if loaded false for any error\r
*/\r
protected boolean loadOriginalData() {\r
- try {\r
- this.raw = IOUtils.toByteArray(inputStream);\r
- } catch (java.io.IOException ex) {\r
- log.error("Error while loading image (EMF): " + ex.getMessage(), ex);\r
- return false;\r
- } finally {\r
- IOUtils.closeQuietly(inputStream);\r
- inputStream = null;\r
- }\r
-\r
- return true;\r
+ return loadDefaultOriginalData();\r
}\r
}\r
\r
return true;
}
+ /** @see org.apache.fop.image.AbstractFopImage#loadOriginalData() */
+ protected boolean loadOriginalData() {
+ return loadDefaultOriginalData();
+ }
+
/**
* A dummy url connection for a gif image in an input stream.
*/
}
}
+ /** @see org.apache.fop.image.AbstractFopImage#loadOriginalData() */
+ protected boolean loadOriginalData() {
+ return loadDefaultOriginalData();
+ }
+
}
}
}
+ /** @see org.apache.fop.image.AbstractFopImage#loadOriginalData() */
+ protected boolean loadOriginalData() {
+ return loadDefaultOriginalData();
+ }
+
}
package org.apache.fop.image;
+import java.awt.color.ColorSpace;
+import java.awt.color.ICC_Profile;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.apache.batik.ext.awt.image.codec.PNGRed;
import org.apache.batik.ext.awt.image.codec.PNGDecodeParam;
import org.apache.batik.ext.awt.image.codec.SeekableStream;
import org.apache.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.commons.io.IOUtils;
+import org.apache.fop.util.CMYKColorSpace;
/**
* FopImage object using PNG
return red;
}
+ /**
+ * Load the original PNG data.
+ * This loads the original PNG data as is into memory.
+ *
+ * @return true if loaded false for any error
+ */
+ protected boolean loadOriginalData() {
+ try {
+ seekableInput.seek(0);
+ this.raw = IOUtils.toByteArray(seekableInput);
+
+ } catch (java.io.IOException ex) {
+ log.error("Error while loading raw image: " + ex.getMessage(), ex);
+ return false;
+ } finally {
+ IOUtils.closeQuietly(inputStream);
+ inputStream = null;
+ }
+
+ return true;
+ }
+
}
// Determine image file format
String file = url.getFile ();
imageformat = FormatBase.determineFormat(imagedata);
- imageformat = imageformat.convert(imageformat, imagedata);
+ if (imageformat != null) {
+ imageformat = imageformat.convert(imageformat, imagedata);
+ }
- if (imageformat.getType() == ImageConstants.I_NOT_SUPPORTED
- | imageformat.getRtfTag() == "") {
+ if (imageformat == null
+ || imageformat.getType() == ImageConstants.I_NOT_SUPPORTED
+ || "".equals(imageformat.getRtfTag())) {
throw new ExternalGraphicException("The tag <fo:external-graphic> "
+ "does not support "
+ file.substring(file.lastIndexOf(".") + 1)