United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6967434 OpenJDK: Round joins/caps of scaled up lines have poor quality.
6967434 : OpenJDK: Round joins/caps of scaled up lines have poor quality.

Details
Type:
Bug
Submit Date:
2010-07-07
Status:
Resolved
Updated Date:
2011-03-07
Project Name:
JDK
Resolved Date:
2010-11-11
Component:
client-libs
OS:
linux
Sub-Component:
2d
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
7

Related Reports
Duplicate:
Duplicate:
Relates:

Sub Tasks

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
                                     
2010-12-04
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...
                                     
2010-11-10



Hardware and Software, Engineered to Work Together