fixed some eps npe's git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195050 13f79535-47bb-0310-9956-ffa450edef68pull/30/head
@@ -49,7 +49,7 @@ public abstract class AbstractFopImage implements FopImage { | |||
protected FopImage.ImageInfo imageInfo = null; | |||
/** | |||
* Image color space (org.apache.fop.datatypes.ColorSpace). | |||
* Image color space (java.awt.color.ColorSpace). | |||
*/ | |||
protected ColorSpace m_colorSpace = null; | |||
@@ -163,7 +163,7 @@ public abstract class AbstractFopImage implements FopImage { | |||
/** | |||
* Return the image color space. | |||
* @return the image color space (org.apache.fop.datatypes.ColorSpace) | |||
* @return the image color space (java.awt.color.ColorSpace) | |||
*/ | |||
public ColorSpace getColorSpace() { | |||
return this.m_colorSpace; |
@@ -20,6 +20,9 @@ import com.sun.jimi.core.*; | |||
// FOP | |||
import org.apache.fop.pdf.PDFColor; | |||
import org.apache.fop.image.analyser.ImageReader; | |||
import org.apache.fop.fo.FOUserAgent; | |||
import org.apache.avalon.framework.logger.Logger; | |||
/** | |||
* FopImage object for several images types, using Jimi. | |||
@@ -38,7 +41,23 @@ public class JimiImage extends AbstractFopImage { | |||
} | |||
} | |||
protected void loadImage() { | |||
protected boolean loadDimensions(FOUserAgent ua) { | |||
if(this.m_bitmaps == null) { | |||
loadImage(ua.getLogger()); | |||
} | |||
return this.m_bitmaps != null; | |||
} | |||
protected boolean loadBitmap(FOUserAgent ua) { | |||
if(this.m_bitmaps == null) { | |||
loadImage(ua.getLogger()); | |||
} | |||
return this.m_bitmaps != null; | |||
} | |||
protected void loadImage(Logger log) { | |||
int[] tmpMap = null; | |||
try { | |||
ImageProducer ip = | |||
@@ -56,9 +75,9 @@ public class JimiImage extends AbstractFopImage { | |||
try { | |||
tmpMap = consumer.getImage(); | |||
} catch (Exception ex) { | |||
/*throw new FopImageException("Image grabbing interrupted : " | |||
+ ex.getMessage()); | |||
*/} | |||
log.error("Image grabbing interrupted", ex); | |||
return; | |||
} | |||
ColorModel cm = consumer.getColorModel(); | |||
this.m_bitsPerPixel = 8; | |||
@@ -118,11 +137,10 @@ public class JimiImage extends AbstractFopImage { | |||
this.m_isTransparent = false; | |||
} | |||
} catch (Exception ex) { | |||
/*throw new FopImageException("Error while loading image " | |||
+ this.m_href.toString() + " : " | |||
+ ex.getClass() + " - " | |||
+ ex.getMessage()); | |||
*/} | |||
log.error("Error while loading image " | |||
+ this.m_href.toString(), ex); | |||
return; | |||
} | |||
// Should take care of the ColorSpace and bitsPerPixel |
@@ -162,14 +162,16 @@ public class FopPDFImage implements PDFImage { | |||
byte[] preBytes = preamble.toString().getBytes(); | |||
byte[] postBytes = post.toString().getBytes(); | |||
byte[] epsBytes = ((EPSImage)fopImage).getEPSImage(); | |||
int epsLength = epsBytes.length; | |||
byte[] imgData = new byte[preBytes.length + postBytes.length + | |||
fopImage.getBitmaps().length]; | |||
epsLength]; | |||
System.arraycopy (preBytes, 0, imgData, 0, preBytes.length); | |||
System.arraycopy (fopImage.getBitmaps(), 0, imgData, | |||
preBytes.length, fopImage.getBitmaps().length); | |||
System.arraycopy (epsBytes, 0, imgData, | |||
preBytes.length, epsBytes.length); | |||
System.arraycopy (postBytes, 0, imgData, | |||
preBytes.length + fopImage.getBitmaps().length, | |||
preBytes.length + epsBytes.length, | |||
postBytes.length); | |||