Browse Source

FOP-2821: 1 bit image fails when using PreloaderRawPNG

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1843560 13f79535-47bb-0310-9956-ffa450edef68
pull/13/head
Simon Steiner 5 years ago
parent
commit
c6fa5cb666

+ 9
- 4
fop-core/src/main/java/org/apache/fop/render/pdf/AbstractImageAdapter.java View File

import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;


import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.impl.ImageRawPNG;
import org.apache.xmlgraphics.image.loader.impl.ImageRendered; import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil; import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;




dict.put("ColorSpace", indexed); dict.put("ColorSpace", indexed);


Raster raster = ((ImageRendered)image).getRenderedImage().getTile(0, 0);
if (raster.getDataBuffer() instanceof DataBufferByte) {
dict.put("BitsPerComponent", icm.getPixelSize());
int bits = 8;
if (image instanceof ImageRawPNG) {
bits = ((ImageRawPNG) image).getBitDepth();
} else { } else {
dict.put("BitsPerComponent", 8);
Raster raster = ((ImageRendered) image).getRenderedImage().getTile(0, 0);
if (raster.getDataBuffer() instanceof DataBufferByte) {
bits = icm.getPixelSize();
}
} }
dict.put("BitsPerComponent", bits);


Integer index = getIndexOfFirstTransparentColorInPalette(icm); Integer index = getIndexOfFirstTransparentColorInPalette(icm);
if (index != null) { if (index != null) {

+ 14
- 0
fop-core/src/test/java/org/apache/fop/render/pdf/ImageRawPNGAdapterTestCase.java View File

PDFICCStream iccStream = irpnga.getICCStream(); PDFICCStream iccStream = irpnga.getICCStream();
assertTrue(ColorProfileUtil.isDefaultsRGB(iccStream.getICCProfile())); assertTrue(ColorProfileUtil.isDefaultsRGB(iccStream.getICCProfile()));
} }

@Test
public void test1BitPNG() throws IOException {
ImageRawPNG imageRawPNG = new ImageRawPNG(null, null,
new IndexColorModel(1, 1, new byte[3], 0, false), 1, null);
ImageRawPNGAdapter imageRawPNGAdapter = new ImageRawPNGAdapter(imageRawPNG, null);
PDFDocument pdfDocument = new PDFDocument("");
PDFDictionary pdfDictionary = new PDFDictionary();
pdfDictionary.setDocument(pdfDocument);
imageRawPNGAdapter.populateXObjectDictionary(pdfDictionary);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
pdfDictionary.output(bos);
assertEquals(bos.toString(), "<< /ColorSpace [/Indexed /DeviceGray 0 <00>] /BitsPerComponent 1 >>");
}
} }

BIN
fop/lib/xmlgraphics-commons-svn-trunk.jar View File


Loading…
Cancel
Save