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).