Author: damjan
Date: Sun Oct 19 06:30:05 2014
New Revision: 1632875
URL: http://svn.apache.org/r1632875
Log:
Allow null parameters in PngImageParser.getBufferedImage(), and add some tests
for null parameters.
Jira issue key: IMAGING-131
Modified:
commons/proper/imaging/trunk/src/changes/changes.xml
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
Modified: commons/proper/imaging/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/changes/changes.xml?rev=1632875&r1=1632874&r2=1632875&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/changes/changes.xml (original)
+++ commons/proper/imaging/trunk/src/changes/changes.xml Sun Oct 19 06:30:05
2014
@@ -46,7 +46,10 @@ The <action> type attribute can be add,u
<body>
<release version="1.0" date="TBA" description="TBA">
- <action issue="IMAGING_121" dev="damjan" type="fix" due-to="Piyush
Kapoor">
+ <action issue="IMAGING-131" dev="damjan" type="fix">
+ Allow null parameters in PngImageParser.getBufferedImage(), and add
some tests for null parameters.
+ </action>
+ <action issue="IMAGING-121" dev="damjan" type="fix" due-to="Piyush
Kapoor">
Null Pointer exception while extracting metadata for CR2 image.
</action>
<action issue="IMAGING-115" dev="damjan" type="fix">
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java?rev=1632875&r1=1632874&r2=1632875&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
(original)
+++
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
Sun Oct 19 06:30:05 2014
@@ -29,6 +29,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.InflaterInputStream;
@@ -468,8 +469,9 @@ public class PngImageParser extends Imag
}
@Override
- public BufferedImage getBufferedImage(final ByteSource byteSource, final
Map<String, Object> params)
+ public BufferedImage getBufferedImage(final ByteSource byteSource,
Map<String, Object> params)
throws ImageReadException, IOException {
+ params = (params == null) ? new HashMap<String, Object>() : new
HashMap<String, Object>(params);
if (params.containsKey(PARAM_KEY_VERBOSE)) {
params.remove(PARAM_KEY_VERBOSE);
Modified:
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java?rev=1632875&r1=1632874&r2=1632875&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
(original)
+++
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
Sun Oct 19 06:30:05 2014
@@ -430,6 +430,25 @@ public class RoundtripTest extends Imagi
}
}
+ public void testNullParametersRoundtrip() throws IOException,
+ ImageReadException, ImageWriteException {
+ final BufferedImage testImage = createFullColorImage(1, 1);
+ for (final FormatInfo formatInfo : FORMAT_INFOS) {
+ if (!formatInfo.canRead || !formatInfo.canWrite) {
+ continue;
+ }
+ final File temp1 = createTempFile("nullParameters.", "."
+ + formatInfo.format.getExtension());
+ Imaging.writeImage(testImage, temp1, formatInfo.format, null);
+ Imaging.getImageInfo(temp1, null);
+ Imaging.getImageSize(temp1, null);
+ Imaging.getMetadata(temp1, null);
+ Imaging.getICCProfile(temp1, null);
+ BufferedImage imageRead = Imaging.getBufferedImage(temp1, null);
+ assertNotNull(imageRead);
+ }
+ }
+
private void roundtrip(final FormatInfo formatInfo, final BufferedImage
testImage,
final String tempPrefix, final boolean imageExact) throws
IOException,
ImageReadException, ImageWriteException {