Skip to content
Browse files

Merge pull request #39 from escenic/upstream

JPEGImageReader throws "IllegalStateException: sourceRegion.height <= subsamplingYOffset!"
  • Loading branch information...
2 parents 037a47c + 822bea8 commit d607450ae436bdb7f05636446d39bfa2383f4d98 @haraldk haraldk committed Mar 2, 2014
View
4 ...io/imageio-jpeg/src/main/java/com/twelvemonkeys/imageio/plugins/jpeg/JPEGImageReader.java
@@ -445,6 +445,10 @@ else if (profile != null) {
for (int y = srcRegion.y; y < srcMaxY; y += step) {
int scan = Math.min(step, srcMaxY - y);
+ if(scan <= param.getSubsamplingYOffset()) {
+ param.setSourceSubsampling(param.getSourceXSubsampling(),param.getSourceYSubsampling(),param.getSubsamplingXOffset(),0);
+ }
+
// Let the progress delegator handle progress, using corrected range
progressDelegator.updateProgressRange(100f * (y + scan) / srcRegion.height);
View
50 ...mageio-jpeg/src/test/java/com/twelvemonkeys/imageio/plugins/jpeg/JPEGImageReaderTest.java
@@ -988,4 +988,54 @@ public int compare(IIOMetadataNode left, IIOMetadataNode right) {
return sortedNodes;
}
+ @Test
+ public void testReadImage1028() throws IOException {
+ JPEGImageReader reader = createReader();
+ reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/read-error1028.jpg")));
+
+ ImageReadParam param = reader.getDefaultReadParam();
+ param.setSourceSubsampling(3, 3, 1, 1);
+ BufferedImage image = reader.read(0, param);
+ assertNotNull(image);
+ }
+ @Test
+ public void testReadImage1027() throws IOException {
+ JPEGImageReader reader = createReader();
+ reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/read-error1027.jpg")));
+
+ ImageReadParam param = reader.getDefaultReadParam();
+ param.setSourceSubsampling(3, 3, 2, 2);
+ BufferedImage image = reader.read(0, param);
+ assertNotNull(image);
+ }
+ @Test
+ public void testReadImage1026() throws IOException {
+ JPEGImageReader reader = createReader();
+ reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/read-error1026.jpg")));
+
+ ImageReadParam param = reader.getDefaultReadParam();
+ param.setSourceSubsampling(3, 3, 1, 1);
+ BufferedImage image = reader.read(0, param);
+ assertNotNull(image);
+ }
+ @Test
+ public void testReadImage1025() throws IOException {
+ JPEGImageReader reader = createReader();
+ reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/read-error1025.jpg")));
+
+ ImageReadParam param = reader.getDefaultReadParam();
+ param.setSourceSubsampling(3, 3, 1, 1);
+ BufferedImage image = reader.read(0, param);
+ assertNotNull(image);
+ }
+ @Test
+ public void testReadImage1024() throws IOException {
+ JPEGImageReader reader = createReader();
+ reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/read-error1024.jpg")));
+
+ ImageReadParam param = reader.getDefaultReadParam();
+ param.setSourceSubsampling(3, 3, 1, 1);
+ BufferedImage image = reader.read(0, param);
+ assertNotNull(image);
+ }
}
View
BIN imageio/imageio-jpeg/src/test/resources/jpeg/read-error1024.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN imageio/imageio-jpeg/src/test/resources/jpeg/read-error1025.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN imageio/imageio-jpeg/src/test/resources/jpeg/read-error1026.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN imageio/imageio-jpeg/src/test/resources/jpeg/read-error1027.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN imageio/imageio-jpeg/src/test/resources/jpeg/read-error1028.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d607450

Please sign in to comment.
Something went wrong with that request. Please try again.