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

[hidpi] invalid repaint for multiresolution image when switching display resolution (Windows)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • tbd
    • 9
    • client-libs

    Description

      OS: Windows 8 + JDK9 b100 + HiDPI display

      Please try to run the following test code and then switch display resolution:


      import java.awt.*;
      import java.awt.event.*;
      import java.awt.image.*;

      public class MultiRes extends Frame {

          private static final int W = 200, H = 200;
          
          private static final BaseMultiResolutionImage IMG =
              new BaseMultiResolutionImage(new BufferedImage[]{
              generateImage(1, Color.BLACK), generateImage(2, Color.BLUE)});

          public MultiRes() { EventQueue.invokeLater(this::CreateUI); }

          private void CreateUI() {
              addWindowListener(new WindowAdapter() {
                  @Override
                  public void windowClosing(WindowEvent e) { dispose(); }
              });
              setSize(W, H);
              setResizable(false);
              setVisible(true);
          }
          
          private static BufferedImage generateImage(int scale, Color c) {

              BufferedImage image = new BufferedImage(
                  scale * W, scale * H, BufferedImage.TYPE_INT_RGB);
              Graphics g = image.getGraphics();
              g.setColor(c);
              g.fillRect(0, 0, scale * W, scale * H);

              g.setColor(Color.WHITE);
              Font f = g.getFont();
              g.setFont(new Font(f.getName(), Font.BOLD, scale * 48));
              g.drawChars(
                  (scale + "X").toCharArray(), 0, 2, scale * W / 2, scale * H / 2);

              return image;
          }
          
          @Override
          public void paint(Graphics gr) {
              Graphics2D g = (Graphics2D) gr;
              if (g != null) { g.drawImage(IMG, 0, 0, this); }
          }

          public static void main(String[] args) { new MultiRes(); }
      }


      Can see some mixture of images instead of the single image (please see the screenshots).

      Attachments

        1. ex1.png
          ex1.png
          7 kB
        2. ex2.png
          ex2.png
          5 kB
        3. ex3.png
          ex3.png
          7 kB

        Issue Links

          Activity

            People

              alexsch Alexandr Scherbatiy
              avstepan Alexander Stepanov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: