JDK-6967434 : OpenJDK: Round joins/caps of scaled up lines have poor quality.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2010-07-07
  • Updated: 2011-03-07
  • Resolved: 2010-11-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b118Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
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.

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/build/jdk/rev/065e6c5a8027
04-12-2010

EVALUATION Denis Lila did a significant amount of work upgrading the quality and performance of the Pisces-based rasterizer used in OpenJDK. This bug, and many others were fixed in the process...
10-11-2010