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

Printing an image with a small rotation transfer outputs black lines at image borders

XMLWordPrintable

    • 2d
    • x86
    • other

      FULL PRODUCT VERSION :
      1.8.0_144
      9.0.4
      1.7.0_80
      1.6.0_45

      ADDITIONAL OS VERSION INFORMATION :
      Windows 10 64 bit

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      We've tested with several versions of Java, from 1.6.0 to 9.0.4, all versions have the problem.

      We've tested with different printers, including printing to XPS or PDF, all printers show the problem.

      A DESCRIPTION OF THE PROBLEM :
      When printing an image using a non-quadrant rotation, the output has added black artifacts at the image borders. We tested using different angles and we always get the artifacts in varying degrees.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a Printable class that prints an image rotated at a non-quadrant angle. When the code is run and the image is printed, there will be black artifacts at the image edges.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No artifacts, only the image should be printed.
      ACTUAL -
      Artifacts at the image edges.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error messages.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.awt.Color;
      import java.awt.Graphics;
      import java.awt.Graphics2D;
      import java.awt.geom.AffineTransform;
      import java.awt.image.BufferedImage;
      import java.awt.print.PageFormat;
      import java.awt.print.Printable;
      import java.awt.print.PrinterException;
      import java.awt.print.PrinterJob;
      import java.io.File;

      import javax.print.PrintService;
      import javax.print.attribute.HashPrintRequestAttributeSet;
      import javax.print.attribute.standard.Destination;

      public class TestPrintBug implements Printable
      {
      public static void main(String [] args)
      {
      try
      {
      PrintService[] services = PrinterJob.lookupPrintServices();
      for (int index = 0; index < services.length; index++)
      {
      if (services[index].getName().equalsIgnoreCase("Microsoft XPS Document Writer"))
      {
      PrinterJob pjob = PrinterJob.getPrinterJob();
      HashPrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
      attributes.add(new Destination(new File("c:/test.xps").toURI()));
      pjob.setPrintable(new TestPrintBug(), new PageFormat());
      pjob.setPrintService(services[index]);
      pjob.print(attributes);
      }
      }
      }
      catch(Throwable t)
      {
      t.printStackTrace();
      }
      }

      @Override
      public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
      {
      if (pageIndex == 0)
      {
      try
      {
      int width = (int)(8.5 * 72);
      int height = 1 * 72;

      BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
      Graphics2D biG = bi.createGraphics();
      biG.setColor(Color.yellow);
      biG.fillRect(0, 0, width, height);

      Graphics2D g2Print = (Graphics2D)graphics;
      g2Print.transform(AffineTransform.getRotateInstance(-0.02));
      g2Print.drawImage(bi, 0, 144, null);

      return Printable.PAGE_EXISTS;
      }
      catch(Throwable t)
      {
      t.printStackTrace();
      }
      }

      return Printable.NO_SUCH_PAGE;
      }
      }
      ---------- END SOURCE ----------

        1. test.xps
          12 kB
          Pardeep Sharma
        2. TestPrintBug.java
          2 kB
          Pardeep Sharma

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: