-
Bug
-
Resolution: Not an Issue
-
P4
-
9
-
os_x
Please save attached image.png, image@2x.png to some folder and compile/run the following test code (in HiDPI mode):
import java.awt.*;
import java.awt.event.*;
import java.io.File;
public class Test extends Frame {
static Image img;
public Test() { EventQueue.invokeLater(this::CreateUI); }
private void CreateUI() {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) { dispose(); }
});
setSize(200, 200);
setVisible(true);
}
@Override
public void paint(Graphics gr) {
Graphics2D g = (Graphics2D) gr;
if (g != null) {
File imageFile = new File("image.png");
String fileName = imageFile.getAbsolutePath();
img = Toolkit.getDefaultToolkit().getImage(fileName);
g.drawImage(img, 50, 50, this);
}
}
public static void main(String[] args) throws Exception { new Test(); }
}
expected behavior - the blue square is drawn.
then corrupt @2x image:
> echo "?!?" > image@2x.png
or
> rm image@2x.png
> touch image@2x.png
and run again - the green square is drawn (this looks reasonable: cannot load @2x image => load @1x image).
please restore image@2x.png and corrupt image.png:
> echo "?!?" > image.png
and run again: image@2x is not loaded. Shouldn't we try to load the uncorrupted image@2x.png? So there is some asymmetry here.
Checked with: Mac OS X 10.10 + Quartz, JDK9 b77
import java.awt.*;
import java.awt.event.*;
import java.io.File;
public class Test extends Frame {
static Image img;
public Test() { EventQueue.invokeLater(this::CreateUI); }
private void CreateUI() {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) { dispose(); }
});
setSize(200, 200);
setVisible(true);
}
@Override
public void paint(Graphics gr) {
Graphics2D g = (Graphics2D) gr;
if (g != null) {
File imageFile = new File("image.png");
String fileName = imageFile.getAbsolutePath();
img = Toolkit.getDefaultToolkit().getImage(fileName);
g.drawImage(img, 50, 50, this);
}
}
public static void main(String[] args) throws Exception { new Test(); }
}
expected behavior - the blue square is drawn.
then corrupt @2x image:
> echo "?!?" > image@2x.png
or
> rm image@2x.png
> touch image@2x.png
and run again - the green square is drawn (this looks reasonable: cannot load @2x image => load @1x image).
please restore image@2x.png and corrupt image.png:
> echo "?!?" > image.png
and run again: image@2x is not loaded. Shouldn't we try to load the uncorrupted image@2x.png? So there is some asymmetry here.
Checked with: Mac OS X 10.10 + Quartz, JDK9 b77