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

1.4.1 REGRESSION: AffineTransform.rotate uses wrong rotation angle

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      rc
    • CPU:
      x86
    • OS:
      windows_xp

      Description



      Name: jk109818 Date: 07/10/2002


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

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Graphics card is Matrox G550 but it shouldn't be involved

      A DESCRIPTION OF THE PROBLEM :
      REGRESSION:
      Using an affineTransform to rotate a bitmap with drawImage
      performs the rotation with wrong rotation angle (half of
      expected angle).

      REGRESSION. Last worked in version 1.4

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run sample with 1.4 => no bug
      2. Run sample with 1.4.1 beta => see the bug
      3.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED result SHOULD BE a bitmap with a rotation angle
      of 90.
      ACTUAL result IS a bitmap with a rotation angle of 45
      degrees.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error message because its a rendering bug

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package bug;
      /*
       * DrawImageRotationBugInJDK1_4_1Beta.java
       *
       * Created on 7 juillet 2002, 17:16
       */
      import javax.imageio.*;
      import java.awt.image.*;
      import java.net.*;
      import java.awt.*;
      import java.awt.geom.*;
      import javax.swing.*;

      /**
       * The result SHOULD BE a bitmap with a rotation angle of 90 degrees.
       * The result IS a bitmap with a rotation angle of 45 degrees.
       *
       * It WAS working in JDK 1.4
       * It IS NOT working in JDK 1.4.1 beta
       *
       * @author Xavier Kral
       */
      public class RotationBug {
          
          /** Creates a new instance of RotationBug */
          public RotationBug() {
          }
          
          public static void main(String[] args) {
              try {
                  BufferedImage source = ImageIO.read(new URL
      ("http://java.sun.com/images/java_logo.gif"));
                  int width = source.getWidth();
                  int height = source.getHeight();
                  BufferedImage target = new BufferedImage(height, width,
      BufferedImage.TYPE_INT_RGB);
                  AffineTransform at = AffineTransform.getTranslateInstance(height,
      0);
                  int rotationAngle = 90;
                  at.rotate(Math.toRadians(rotationAngle));
                  // apply rotation via AT
                  Graphics2D g2 = target.createGraphics();
                  g2.drawImage(source, at, null);
                  JFrame frame = new JFrame();
                  frame.getContentPane().add(new JLabel(new ImageIcon(target)));
                  frame.pack();
                  frame.show();
              } catch (Exception ex) {
                  ex.printStackTrace();
              }
          }
      }

      ---------- END SOURCE ----------
      (Review ID: 159001)
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            campbell Christopher Campbell (Inactive)
            Reporter:
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: