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

Method Graphics2D.drawImage(...) stops a run of program

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 5.0
    • client-libs

      FULL PRODUCT VERSION :
      5.0_06

      A DESCRIPTION OF THE PROBLEM :
      Method Graphics2D.drawImage(...) stops a run of program in case, the image is modified by Photoshop version 8.0.1 . See source code for detail.

      Notes:
      - no exception appears
      - using the method setRenderingHint(...) is fundamental
      - the method drawImage() envokes an never ending loop probably.
      - resize solution by AfineTransformOp class is the same wrong.
      - the image files are not corrupted and can be opened simply by MSIE, Mozilla and more viewers.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Resize an image.
      ACTUAL -
      Method Graphics2D.drawImage(...) stops a program

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /* Source include Photoshop image:
      * http://java_img_test.pponec.net/TEST.ZIP
      */

      package test;

      import java.awt.Graphics2D;
      import java.awt.RenderingHints;
      import java.awt.image.BufferedImage;
      import java.io.InputStream;
      import java.util.Iterator;
      import javax.imageio.ImageIO;
      import javax.imageio.ImageReadParam;
      import javax.imageio.ImageReader;
      import javax.imageio.stream.ImageInputStream;


      public class PhotoTest {
          
          public void test() throws Throwable {
              // The Image was modifiled by Photoshop:
              InputStream file = getClass().getResourceAsStream("/test/img.jpg");
              
              Iterator readers = ImageIO.getImageReadersBySuffix("jpg");
              ImageReader reader = (ImageReader) readers.next();
              ImageInputStream iis = ImageIO.createImageInputStream(file);
              reader.setInput(iis, true); // true means SingleFrame
              ImageReadParam param = reader.getDefaultReadParam();
              BufferedImage imgOriginal = reader.read(0, param);
              iis.close();
              
              // Make a thumbnail:
              BufferedImage imgSmall = new BufferedImage(700, 75, imgOriginal.getType());
              Graphics2D graphics2D = imgSmall.createGraphics();
              graphics2D.setRenderingHint
              ( RenderingHints.KEY_INTERPOLATION
              , RenderingHints.VALUE_INTERPOLATION_BILINEAR
              ) ;
              
              System.out.println("STARTING drawImage(...)");
              // --- THE LAST STATEMENT: ----
              graphics2D.drawImage(imgOriginal, 0, 0, 100, 75, null);
              System.out.println("FINISHED drawImage(...)");
              graphics2D.dispose();
          }
          
          /** Run the class */
          public static void main(String[] args) {
              try {
                  new PhotoTest().test();
              } catch (Throwable e) {
                  e.printStackTrace();
              }
          }
      }

      ---------- END SOURCE ----------

            jdv Jayathirth D V
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: