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

Long line when path.curveTo() is drawn with RenderingHint VALUE_ANTIALIAS_ON

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • Understanding:
      Cause Known
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10.0.19043.1348

      A DESCRIPTION OF THE PROBLEM :
      Running the attached code creates a long line in the produced image

      REGRESSION : Last worked in version 8u311

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run code
      open the result PNG image


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      very tiny black line
      ACTUAL -
      long black line

      ---------- BEGIN SOURCE ----------

      import java.awt.Color;
      import java.awt.Graphics2D;
      import java.awt.RenderingHints;
      import java.awt.geom.AffineTransform;
      import java.awt.geom.GeneralPath;
      import java.awt.image.BufferedImage;
      import java.io.File;
      import java.io.IOException;
      import javax.imageio.ImageIO;

      public class PDFBOX_5322
      {
          public static void main(String[] args) throws IOException
          {
              BufferedImage bim = new BufferedImage(623, 311, BufferedImage.TYPE_INT_RGB);
              Graphics2D g2d = (Graphics2D) bim.getGraphics();
              g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
              g2d.setBackground(Color.white);
              g2d.clearRect(0, 0, bim.getWidth(), bim.getHeight());
              g2d.setColor(Color.black);
              g2d.transform(new AffineTransform(1f, 0f, 0f, -1f, 0, 311f));
              GeneralPath path = new GeneralPath();
              path.moveTo(438.5315f, 261.2291f);
              path.curveTo(437.8919f, 265.3086f, 437.6903f, 265.3338f, 437.6903f, 265.3338f);
              path.curveTo(437.5043f, 265.3571f, 437.3822f, 265.2621f, 437.3822f, 265.2621f);
              g2d.draw(path);
              g2d.dispose();
              ImageIO.write(bim, "png", new File("PDFBOX-5322.png"));
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use jdk8, or don't use antialiasing

      FREQUENCY : always


        Attachments

        1. 1.8.0_311.png
          1.8.0_311.png
          1 kB
        2. 18-ea.png
          18-ea.png
          3 kB
        3. PDFBOX_5322.java
          1 kB

          Activity

            People

            Assignee:
            lbourges Laurent Bourg├Ęs
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Dates

              Created:
              Updated: