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

ThinLineTest: A line < 1 pixel disappears.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7
    • 7
    • client-libs
    • 2d
    • b74
    • generic
    • generic

        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.");
            }
          }
        }

              jgodinez Jennifer Godinez (Inactive)
              jgodinez Jennifer Godinez (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: