Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6444933

ImageIO creates faulty images of certain standard JPG files

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic, x86
    • OS:
      generic, windows_2000, windows_xp, windows_vista

      Backports

        Description

        FULL PRODUCT VERSION :
        java version " 1.5.0_06"
        java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
        Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Windows XP Service Pack 2

        A DESCRIPTION OF THE PROBLEM :
        Java ImageIO reads certain JPG files and generates faulty images looking like a red-filter has been applied.
        These JPEGS work fine using other Imaging-Applications like IRFANVIEW, Photoshop etc. and are also displayed correctly in any browser.

        Even using the "old" java way, using the Toolkit Classes works fine (java.awt.Toolkit.getDefaultToolkit().createImage(...) ).

        Just Java ImageIO produces these red images.
        This problem seems to be a similar one as bug #4881314, but is not fixed in 1.5.0_04 as mentioned there.

        This also occurs with:
        J2SE 1.4.1_06 on Windows XP
        J2SE 1.4.2_06 on Windows XP
        J2SE 1.5.0_03 on Windows XP
        and with latest release as mentioned above
        J2SE 1.5.0_06 on Windows XP


        The code necessary to reproduce this behaviour looks like:

        File f = new File("W:/java/ImageIORedColored-1.jpg");
        //File f = new File("W:/java/ImageIORedColored-2.jpg");
        BufferedImage bi = ImageIO.read(f);

        JFrame f = new JFrame();
        JLabel l = new JLabel(new ImageIcon(bi));
        f.setContentPane(l);
        f.pack();
        f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        f.setVisible(true);


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Examples of affected JPEGs can be found here:
        http://cobra.levigo.de/java/ImageIORedColored-1.jpg and
        http://cobra.levigo.de/java/ImageIORedColored-2.jpg

        Start the appended JPEG_Test Demo application.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The generated image should have the correct colors.
        ACTUAL -
        The generated image looks if a red filter has been applied.

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        No error messages

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public class JPEG_Test extends JFrame{

        JPEG_Test(){
        super("ImageIO JPEG Test");

           File f = new File("W:/java/ImageIORedColored-1.jpg");
        // File f = new File("W:/java/ImageIORedColored-2.jpg");
           BufferedImage bi = null;
           try {
        bi = ImageIO.read(f);
        } catch (IOException e) {
        e.printStackTrace();
        }

            JLabel l = null;
            if (bi != null)
             l = new JLabel(new ImageIcon(bi));
            else
             l = new JLabel("Problems occured.");
            
            setContentPane(l);
            pack();
            setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            setVisible(true);
        }

        public static void main(String[] args) {
           new JPEG_Test();
        }
        }
        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                prr Philip Race
                Reporter:
                igor Igor Nekrestyanov (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: