You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by ss...@apache.org on 2018/10/11 14:59:17 UTC
svn commit: r1843559 - in /xmlgraphics/commons/trunk/src:
main/java/org/apache/xmlgraphics/image/loader/impl/
test/java/org/apache/xmlgraphics/image/loader/impl/
Author: ssteiner
Date: Thu Oct 11 14:59:17 2018
New Revision: 1843559
URL: http://svn.apache.org/viewvc?rev=1843559&view=rev
Log:
FOP-2821: 1 bit image fails when using PreloaderRawPNG
Modified:
xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java
xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/image/loader/impl/PNGFile.java
xmlgraphics/commons/trunk/src/test/java/org/apache/xmlgraphics/image/loader/impl/PNGFileTestCase.java
Modified: xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java?rev=1843559&r1=1843558&r2=1843559&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java (original)
+++ xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java Thu Oct 11 14:59:17 2018
@@ -70,7 +70,7 @@ public class ImageLoaderRawPNG extends A
// Remove streams as we do things with them at some later time.
XmlSourceUtil.removeStreams(src);
SeekableStream seekStream = new ImageInputStreamSeekableStreamAdapter(in);
- PNGFile im = new PNGFile(seekStream);
+ PNGFile im = new PNGFile(seekStream, info.getOriginalURI());
ImageRawPNG irpng = im.getImageRawPNG(info);
return irpng;
}
Modified: xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/image/loader/impl/PNGFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/image/loader/impl/PNGFile.java?rev=1843559&r1=1843558&r2=1843559&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/image/loader/impl/PNGFile.java (original)
+++ xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/image/loader/impl/PNGFile.java Thu Oct 11 14:59:17 2018
@@ -69,7 +69,7 @@ class PNGFile implements PNGConstants {
private boolean hasPalette;
private boolean hasAlphaPalette;
- public PNGFile(InputStream stream) throws IOException, ImageException {
+ public PNGFile(InputStream stream, String uri) throws IOException, ImageException {
if (!stream.markSupported()) {
stream = new BufferedInputStream(stream);
}
@@ -107,12 +107,14 @@ class PNGFile implements PNGConstants {
chunk = PNGChunk.readChunk(distream);
parse_sRGB_chunk(chunk);
} else {
- // chunk = PNGChunk.readChunk(distream);
+ if (Character.isUpperCase(chunkType.charAt(0))) {
+ throw new ImageException("PNG unknown critical chunk: " + chunkType);
+ }
PNGChunk.skipChunk(distream);
}
} catch (Exception e) {
String msg = PropertyUtil.getString("PNGImageDecoder2");
- throw new RuntimeException(msg, e);
+ throw new RuntimeException(msg + " " + uri, e);
}
} while (true);
}
@@ -190,10 +192,6 @@ class PNGFile implements PNGConstants {
private void parse_IHDR_chunk(PNGChunk chunk) {
bitDepth = chunk.getInt1(8);
- if (bitDepth != 8) {
- // this is a limitation of the current implementation
- throw new RuntimeException("Unsupported bit depth: " + bitDepth);
- }
colorType = chunk.getInt1(9);
int compressionMethod = chunk.getInt1(10);
if (compressionMethod != 0) {
Modified: xmlgraphics/commons/trunk/src/test/java/org/apache/xmlgraphics/image/loader/impl/PNGFileTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/test/java/org/apache/xmlgraphics/image/loader/impl/PNGFileTestCase.java?rev=1843559&r1=1843558&r2=1843559&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/test/java/org/apache/xmlgraphics/image/loader/impl/PNGFileTestCase.java (original)
+++ xmlgraphics/commons/trunk/src/test/java/org/apache/xmlgraphics/image/loader/impl/PNGFileTestCase.java Thu Oct 11 14:59:17 2018
@@ -28,7 +28,6 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageException;
@@ -77,12 +76,13 @@ public class PNGFileTestCase implements
ImageSessionContext session = new MockImageSessionContext(context);
ImageInfo info = new ImageInfo("corrupt-image.png", MimeConstants.MIME_PNG);
ImageLoaderRawPNG ilrpng = new ImageLoaderRawPNG();
+ String exception = "";
try {
- ImageRawPNG irpng = (ImageRawPNG) ilrpng.loadImage(info, null, session);
- fail("An exception should have been thrown above");
+ ilrpng.loadImage(info, null, session);
} catch (Exception e) {
- // do nothing; this was expected
+ exception = e.getCause().getMessage();
}
+ assertEquals("PNG unknown critical chunk: IBLA", exception);
}
private void testColorTypePNG(String imageName, int colorType) throws ImageException, IOException {
@@ -115,5 +115,4 @@ public class PNGFileTestCase implements
assertTrue(irpng.isTransparent());
}
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org