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

ImageIO fails to decode some YCbCr JPEGs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • client-libs

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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      ImageIO still fails to properly decode some YCbCr JPEG images (e.g. those scanned using Nikon CoolScan). The colors are shifted (red and blue channels are swapped).

      See bug #4712797 for a similar problem I reported previously which is now fixed.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the attached sample program and run:

      java JpegView http://www.photica.com/aw/jpeg-colors.jpg

      JpegView displays a window, the image on the
      left was decoded with ImageIO and is wrong, the image on
      the right was decoded with java.awt.Toolkit.createImage()
      and looks correct.

      Another sample image with the same problem is available here: http://www4.ncsu.edu/~zdpurvis/JPEGColorBugDemo.zip


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Both images should look like the image on the right.
      ImageIO should not behave differently from the
      java.awt.Toolkit JPEG decoder and from other image viewing applications.
      ACTUAL -
      Shifted colors.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.imageio.*;
      import java.awt.image.*;
      import java.io.*;
      import javax.swing.*;
      import java.awt.*;
      import java.net.*;

      public class JpegView {
      public static void main(String args[]) throws Exception {
      if (args.length < 1) {
      System.err.println("Usage: JpegView <jpeg-url>");
      System.exit(1);
      }
      ImageIcon iiImageIO = new ImageIcon(ImageIO.read(new URL(args
      [0])));
      ImageIcon iiToolkit = new ImageIcon(Toolkit.getDefaultToolkit
      ().createImage(new URL(args[0])));

      JFrame f= new JFrame();
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JLabel lblImageIO = new JLabel(iiImageIO);
      JLabel lblToolkit = new JLabel(iiToolkit);
      f.getContentPane().add(lblImageIO, BorderLayout.WEST);
      f.getContentPane().add(lblToolkit, BorderLayout.EAST);
      f.pack();
      f.setVisible(true);
      }
      }


      ---------- END SOURCE ----------
      ###@###.### 2005-03-28 10:09:35 GMT

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: