United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6829673 ThinLineTest: A line < 1 pixel disappears.
JDK-6829673 : ThinLineTest: A line < 1 pixel disappears.

Details
Type:
Bug
Submit Date:
2009-04-13
Status:
Resolved
Updated Date:
2010-06-10
Project Name:
JDK
Resolved Date:
2009-10-06
Component:
client-libs
OS:
generic
Sub-Component:
2d
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:

Sub Tasks

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
                                     
2009-04-17



Hardware and Software, Engineered to Work Together