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

8bit monochrome jpeg images are displayed too bright

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • client-libs



      Name: rmT116609 Date: 05/06/2004


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

      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP

      A DESCRIPTION OF THE PROBLEM :
      - When loading an 8-bit monochrome jpeg image via ImageIO.read(..), the image is displayed too bright. This does not happen when the image is loaded via Toolkit.createImage(..).
      - This problem is visible when using Graphics2D for displaying with a scaling != 1 (via AffineTransform) and certain RenderingHints.
      For the exact parameters, please see the code example.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use the code example below. Compare the 2 image renderings; also use an image viewer (like IrfanView) to compare the appearance.
      You can use the 8-bit monochrome image from
      http://www.deutsche-synchronsprecher.de/baltho.jpg
      and copy it into the classes folder, using the name "image.jpg".



      REPRODUCIBILITY :
      This bug can be reproduced always.

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


      public class JImagePanel extends JPanel
      {
        Image xImage;
        java.awt.geom.AffineTransform xPaintScaling;
        
        public JImagePanel(Image xImage)
        {
          this.xImage = xImage;
          xPaintScaling = new java.awt.geom.AffineTransform();
        }
        
        public void paintComponent(Graphics g)
        {
          xPaintScaling.setToScale(1.2, 1.2);
          Graphics2D gg = (Graphics2D)g;
          gg.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
            RenderingHints.VALUE_INTERPOLATION_BICUBIC);
          gg.drawImage(xImage, xPaintScaling, JImagePanel.this);
        }
        
        public static void main(String[] args)
        {
          try
          {
            JFrame xJFrame = new JFrame();
            
            // The image must be an 8-bit monochrome JPEG
            String name = "image.jpg";
            
            Image xImage1 = Toolkit.getDefaultToolkit().createImage(name);
            
            // The following image is displayed too bright:
            Image xImage2 = javax.imageio.ImageIO.read(new File(name));
            
            JSplitPane xJSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
              new JImagePanel(xImage1), new JImagePanel(xImage2));
            xJFrame.getContentPane().add(xJSplitPane);
            
            xJFrame.setSize(800, 600);
            xJFrame.setVisible(true);
            xJSplitPane.setDividerLocation(0.5);
          }
          catch(Exception e)
          {
          }
        }
      }


      ---------- END SOURCE ----------
      (Incident Review ID: 260739)
      ======================================================================

            bae Andrew Brygin
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: