package org.apache.fop.render.pdf;
import java.awt.color.ColorSpace;
import java.awt.color.ICC_Profile;
+import java.awt.image.DataBufferByte;
import java.awt.image.IndexColorModel;
+import java.awt.image.Raster;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xmlgraphics.image.loader.Image;
+import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
import org.apache.fop.pdf.PDFArray;
indexed.add(baout.toByteArray());
dict.put("ColorSpace", indexed);
- dict.put("BitsPerComponent", icm.getPixelSize());
+
+ Raster raster = ((ImageRendered)image).getRenderedImage().getTile(0, 0);
+ if (raster.getDataBuffer() instanceof DataBufferByte) {
+ dict.put("BitsPerComponent", icm.getPixelSize());
+ } else {
+ dict.put("BitsPerComponent", 8);
+ }
Integer index = getIndexOfFirstTransparentColorInPalette(icm);
if (index != null) {
*/
public ImageRenderedAdapter(ImageRendered image, String key) {
super(image, key);
- this.encodingHelper = new ImageEncodingHelper(image.getRenderedImage(), true);
+ this.encodingHelper = new ImageEncodingHelper(image.getRenderedImage());
}
/**
/** {@inheritDoc} */
public void outputContents(OutputStream out) throws IOException {
long start = System.currentTimeMillis();
+ encodingHelper.setBWInvert(true);
encodingHelper.encode(out);
long duration = System.currentTimeMillis() - start;
if (log.isDebugEnabled()) {
ImageEncodingHelper helper = new ImageEncodingHelper(ri);
ColorModel cm = helper.getEncodedColorModel();
- PSImageUtils.writeImage(encoder, imgDim, imgDescription, targetRect, cm, gen);
+ PSImageUtils.writeImage(encoder, imgDim, imgDescription, targetRect, cm, gen, ri);
}
/** {@inheritDoc} */