JDK-6829673 : ThinLineTest: A line < 1 pixel disappears.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-04-13
  • Updated: 2010-06-10
  • Resolved: 2009-10-06
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 Other
7 b74Fixed OpenJDK6Fixed
Description
Bugzilla submission:
ThinLineTest: A line < 1 pixel disappears.

---------ThinLineTest.java---------
import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

/**
 * @author ###@###.### (Chris Nokleberg)
 * @author ###@###.### (Hiroshi Yamauchi)
 */
public class ThinLineTest {
  private static final int PIXEL = 381;

  public static void main(String[] args) throws Exception {
    BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = image.createGraphics();

    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setPaint(Color.WHITE);
    g.fill(new Rectangle(image.getWidth(), image.getHeight()));

    g.scale(0.5 / PIXEL, 0.5 / PIXEL);
    g.setPaint(Color.BLACK);
    g.setStroke(new BasicStroke(PIXEL));
    g.draw(new Ellipse2D.Double(PIXEL * 50, PIXEL * 50, PIXEL * 300, PIXEL * 300));

    // To visually check it
    //ImageIO.write(image, "PNG", new File(args[0]));

    boolean nonWhitePixelFound = false;
    for (int x = 0; x < 200; ++x) {
      if (image.getRGB(x, 100) != Color.WHITE.getRGB()) {
        nonWhitePixelFound = true;
        break;
      }
    }
    if (!nonWhitePixelFound) {
      throw new RuntimeException("The thin line disappeared.");
    }
  }
}

Comments
EVALUATION See evaluation in the patch submitted by rkennke: https://bugs.openjdk.java.net/show_bug.cgi?id=100031
17-04-2009