-
Bug
-
Resolution: Fixed
-
P2
-
1.4.0
-
None
-
beta
-
generic
-
generic, solaris_7
The following test program reads image 0 and 1 from a given JPEG file.
Image 0 is read O.K., but the attempt to read the non-existent image at
index 1 fails with an IIOException from the underlying library. Instead,
the EOF condition should be detected and an IndexOutOfBoundsException
should be thrown.
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import com.sun.imageio.plugins.jpeg.JPEGImageReader;
public class JPEGMultiImage {
public static void main(String[] args) throws IOException {
File f = new File(args[0]);
if (!f.exists()) {
throw new RuntimeException("No such file: " + filename);
}
// Try reading image 0, all should be O.K.
ImageReader reader = null;
try {
ImageInputStream iis = ImageIO.createImageInputStream(f);
reader = new JPEGImageReader(null);
reader.setInput(iis, true);
reader.read(0);
} catch (IOException ioe0) {
throw new RuntimeException("Got exception reading image 0: " +
ioe0);
}
// Now try reading non-existing image 1
try {
reader.read(1);
} catch (IOException ioe1) {
throw new RuntimeException("Got exception reading image 1: " +
ioe1);
}
}
}
Image 0 is read O.K., but the attempt to read the non-existent image at
index 1 fails with an IIOException from the underlying library. Instead,
the EOF condition should be detected and an IndexOutOfBoundsException
should be thrown.
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import com.sun.imageio.plugins.jpeg.JPEGImageReader;
public class JPEGMultiImage {
public static void main(String[] args) throws IOException {
File f = new File(args[0]);
if (!f.exists()) {
throw new RuntimeException("No such file: " + filename);
}
// Try reading image 0, all should be O.K.
ImageReader reader = null;
try {
ImageInputStream iis = ImageIO.createImageInputStream(f);
reader = new JPEGImageReader(null);
reader.setInput(iis, true);
reader.read(0);
} catch (IOException ioe0) {
throw new RuntimeException("Got exception reading image 0: " +
ioe0);
}
// Now try reading non-existing image 1
try {
reader.read(1);
} catch (IOException ioe1) {
throw new RuntimeException("Got exception reading image 1: " +
ioe1);
}
}
}
- duplicates
-
JDK-4411947 The Reader.readAll() fails for JPEG plugin
-
- Closed
-