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

Screenshot taken with Robot.createScreenCapture() is blurred on Retina Display

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      os_x

      Description

      ADDITIONAL SYSTEM INFORMATION :
      macOS 10.13.5, tested with Java 1.8, 10.0.1 and 11-ea.

      A DESCRIPTION OF THE PROBLEM :
      I am using macOS 10.13.5 on a Macbook pro 2015. In my application I am using the Robot class to take a screenshot of a part of the screen. When I display the BufferedImage it ist blurred/unsharp and does not correspond to the original image. Screenshots taken with other (not JAVA) applications do not show this problem.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use Robot.createScreenCapture on an Retina display under macOS, and display the buffered image. Here are three images which display the problem: https://schrell.de/java-bug

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      a one to one image
      ACTUAL -
      a blurred image which is not identical to the original screen

      ---------- BEGIN SOURCE ----------
      import java.awt.AWTException;
      import java.awt.Rectangle;
      import java.awt.Robot;
      import java.awt.image.BufferedImage;

      import javax.swing.ImageIcon;
      import javax.swing.JFrame;
      import javax.swing.JLabel;

      public class Test extends JFrame {

          private static final long serialVersionUID = 1802199483736051124L;

          public static void main(final String[] args) throws AWTException {
              final Robot robot = new Robot();
              final BufferedImage bufferedImage = robot.createScreenCapture(new Rectangle(0, 0, 200, 200));
              final JFrame imFrame = new Test();
              imFrame.add(new JLabel(new ImageIcon(bufferedImage)));
              imFrame.setSize(bufferedImage.getWidth() + 50,
                      bufferedImage.getHeight() + 50);
              imFrame.pack();
              imFrame.setVisible(true);

          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

        1. screenshot1.png
          screenshot1.png
          71 kB
        2. screenshot2.png
          screenshot2.png
          514 kB
        3. screenshot3.png
          screenshot3.png
          27 kB
        4. Test.java
          0.8 kB

          Activity

            People

            Assignee:
            skodandarama Suman Rajkumaar Kodandarama
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: