-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
6u10
-
x86
-
windows_vista
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) Client VM (build 14.1-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows Vista Home Premium Service Pack 1
A DESCRIPTION OF THE PROBLEM :
Pixel data from files read with imageIO appear to be incorrect when the images were previously saved using Photoshop and selecting either ICC Profile Adobe (1998) or sRGB IEC61966-2.1 in the Save As dialog box.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Save an image with Photoshop (Elements 5) and select either ICC Profile Adobe RGB (1998) or sRGB IEC61966-2.1. Use ImageIO to read the file and then read the pixel data to create a histogram.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Number of pixels for each level (0-255) should be accurate and if used to create a histogram, should match those displayed using Photoshop or GIMP, etc.
ACTUAL -
A few pixel levels are wrong.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error, just bad data.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.*;
public class bugTest {
public bugTest() {
try {
BufferedImage img = null;
//ICC Profile Adobe RGB (1998)
//String filename = "testImageAdobe.jpg";
//ICC Profile sRGB IEC61966-2.1
String filename = "testImageRGB.jpg";
//This way it doesn't work
img = ImageIO.read(new File(filename));
int[] histGreen = new int[256];
int[] pixels = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth());
for (int x = 0; x < pixels.length; x++) {
Color pixelColor = new Color(pixels[x]);
histGreen[pixelColor.getGreen()]++;
}
for (int x = 0; x < histGreen.length; x++) {
System.out.println("Green[" + x + "]=" + histGreen[x]);
}
}catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new bugTest();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use either
java.awt.Toolkit.getDefaultToolkit().createImage(filename);
or
JAI.create("fileload", fileName).getAsBufferedImage();
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) Client VM (build 14.1-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows Vista Home Premium Service Pack 1
A DESCRIPTION OF THE PROBLEM :
Pixel data from files read with imageIO appear to be incorrect when the images were previously saved using Photoshop and selecting either ICC Profile Adobe (1998) or sRGB IEC61966-2.1 in the Save As dialog box.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Save an image with Photoshop (Elements 5) and select either ICC Profile Adobe RGB (1998) or sRGB IEC61966-2.1. Use ImageIO to read the file and then read the pixel data to create a histogram.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Number of pixels for each level (0-255) should be accurate and if used to create a histogram, should match those displayed using Photoshop or GIMP, etc.
ACTUAL -
A few pixel levels are wrong.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error, just bad data.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.*;
public class bugTest {
public bugTest() {
try {
BufferedImage img = null;
//ICC Profile Adobe RGB (1998)
//String filename = "testImageAdobe.jpg";
//ICC Profile sRGB IEC61966-2.1
String filename = "testImageRGB.jpg";
//This way it doesn't work
img = ImageIO.read(new File(filename));
int[] histGreen = new int[256];
int[] pixels = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth());
for (int x = 0; x < pixels.length; x++) {
Color pixelColor = new Color(pixels[x]);
histGreen[pixelColor.getGreen()]++;
}
for (int x = 0; x < histGreen.length; x++) {
System.out.println("Green[" + x + "]=" + histGreen[x]);
}
}catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new bugTest();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use either
java.awt.Toolkit.getDefaultToolkit().createImage(filename);
or
JAI.create("fileload", fileName).getAsBufferedImage();