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

Round joins/caps of scaled up lines have poor quality.

    XMLWordPrintable

Details

    • 2d
    • x86
    • linux

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0_18"
      OpenJDK Runtime Environment (IcedTea6 1.8) (fedora-41.b18.fc13-x86_64)
      OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      2.6.33.5-124.fc13.x86_64 #1 SMP Fri Jun 11 09:38:12 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      When a thin line is drawn with round joins or end caps, and with an affine transformation that magnifies, the end caps and joins don't look round at all.

      This is because of how round end caps and joins are drawn in Pisces. A circle arc is drawn as many tiny lines, each with a length of approximately one pixel. The number of these lines is computed using the line width. The problem is that the effect of the transformation on the line width is not taken into account.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the provided code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A round end cap is drawn at the ends of the white line (in the output image test.png)
      ACTUAL -
      The end cap looks triangular.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.geom.*;
      import java.awt.image.*;
      import javax.imageio.*;

      public class TestDBZ extends Frame {

          public static void main(String[] args) {
              BufferedImage bImg = new BufferedImage(512, 512, BufferedImage.TYPE_INT_RGB);
              Graphics2D g2d = (Graphics2D) bImg.getGraphics();

              g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10.0f));//, new float[] {12f, 12f}, 0));

              g2d.scale(20, 20);
              g2d.drawLine(2, 2, 10, 10);
              try { ImageIO.write(bImg, "png", new java.io.File("test.png")); } catch (Exception e) {}
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Not much one can do, except not use transforms or round joins.

      Attachments

        Issue Links

          Activity

            People

              flar Jim Graham
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: