-
Bug
-
Resolution: Unresolved
-
P4
-
9
Please run the following test code:
import java.io.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.imageio.*;
import javax.imageio.stream.*;
public class Test {
private final String format = "tiff";
private ImageWriter getWriter() {
java.util.Iterator<ImageWriter> writers =
ImageIO.getImageWritersByFormatName(format);
if (!writers.hasNext()) {
throw new RuntimeException("No writers available for " + format);
}
return writers.next();
}
private static final int TYPES[] = {
BufferedImage.TYPE_USHORT_565_RGB,
BufferedImage.TYPE_USHORT_555_RGB};
private static final String NAMES[] = {
"TYPE_USHORT_565_RGB",
"TYPE_USHORT_555_RGB"};
private BufferedImage getImage(int type) {
int l = 100;
BufferedImage img = new BufferedImage(l, l, type);
Graphics g = img.getGraphics();
g.setColor(Color.BLACK);
g.fillRect(0, 0, l, l);
g.setColor(Color.WHITE);
g.fillRect(15, 15, l - 30, l - 30);
g.dispose();
return img;
}
private void run() throws IOException {
ImageWriter writer = getWriter();
for (int i = 0; i < TYPES.length; i++) {
BufferedImage bi = getImage(TYPES[i]);
File out = new File("out-" + NAMES[i] + "." + format);
ImageOutputStream ios = ImageIO.createImageOutputStream(out);
writer.setOutput(ios);
writer.write(new IIOImage(bi, null, null));
ios.flush();
writer.dispose();
}
}
public static void main(String[] args) throws IOException { (new Test()).run(); }
}
The colors for out-TYPE_USHORT_555_RGB.tiff will be biased (please see the image attached) - RGB = {255, 125, 255} in the center.
Then remove "TYPE_USHORT_565_RGB" from TYPES and NAMES - the image will have proper (white) color in the center.
No issues for, e.g., PNG format.
JDK/OS: JDK9 b113 + Windows 7
The issue is closely connected toJDK-8150154 (and is covered by RepeatingWriteTest.java as well).
import java.io.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.imageio.*;
import javax.imageio.stream.*;
public class Test {
private final String format = "tiff";
private ImageWriter getWriter() {
java.util.Iterator<ImageWriter> writers =
ImageIO.getImageWritersByFormatName(format);
if (!writers.hasNext()) {
throw new RuntimeException("No writers available for " + format);
}
return writers.next();
}
private static final int TYPES[] = {
BufferedImage.TYPE_USHORT_565_RGB,
BufferedImage.TYPE_USHORT_555_RGB};
private static final String NAMES[] = {
"TYPE_USHORT_565_RGB",
"TYPE_USHORT_555_RGB"};
private BufferedImage getImage(int type) {
int l = 100;
BufferedImage img = new BufferedImage(l, l, type);
Graphics g = img.getGraphics();
g.setColor(Color.BLACK);
g.fillRect(0, 0, l, l);
g.setColor(Color.WHITE);
g.fillRect(15, 15, l - 30, l - 30);
g.dispose();
return img;
}
private void run() throws IOException {
ImageWriter writer = getWriter();
for (int i = 0; i < TYPES.length; i++) {
BufferedImage bi = getImage(TYPES[i]);
File out = new File("out-" + NAMES[i] + "." + format);
ImageOutputStream ios = ImageIO.createImageOutputStream(out);
writer.setOutput(ios);
writer.write(new IIOImage(bi, null, null));
ios.flush();
writer.dispose();
}
}
public static void main(String[] args) throws IOException { (new Test()).run(); }
}
The colors for out-TYPE_USHORT_555_RGB.tiff will be biased (please see the image attached) - RGB = {255, 125, 255} in the center.
Then remove "TYPE_USHORT_565_RGB" from TYPES and NAMES - the image will have proper (white) color in the center.
No issues for, e.g., PNG format.
JDK/OS: JDK9 b113 + Windows 7
The issue is closely connected to
- blocks
-
JDK-8163323 javax/imageio/plugins/shared/RepeatingWriteTest fails image check for TIFF
-
- Open
-
- relates to
-
JDK-8150154 AIOOB Exception during sequential write of TIFF images
-
- Resolved
-