-
Bug
-
Resolution: Fixed
-
P3
-
8u192, 11
-
b23
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8207291 | 12 | Krishna Addepalli | P3 | Resolved | Fixed | b03 |
JDK-8207498 | 11.0.2 | Krishna Addepalli | P3 | Resolved | Fixed | b01 |
JDK-8207609 | 11.0.1 | Krishna Addepalli | P3 | Resolved | Fixed | b02 |
Images are not scaled correctly when JEditorPane is used to display HTML content if only width is specified for the image. Height is not scaled as expected to maintain the aspect ratio. A circle of 100x100px and width specified as 200 scaled to an ellipse of height 100 and width 200. It should scaled to a circle with diameter 200.
Use below test program and attached image to reproduce the issue.
------------------------------------
ImageTest.java
============
import javax.swing.*;
public class ImageTest {
private static final String ABSOLUTE_FILE_PATH =
"c:\\ws\\Test\\src\\test\\circle.png";
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame f = new JFrame();
// the following line is expected to work in the same
//way
//as the next (commented) line, as the image has aspect ratio 1:1
JEditorPane editorPane = new JEditorPane("text/html",
"<img width=\"200\" src=\"file:///" + ABSOLUTE_FILE_PATH + "\">");
// JEditorPane editorPane = new JEditorPane("text/html",
//"<img width=\"200\" height=\"200\" src=\"file:///" + ABSOLUTE_FILE_PATH +
//"\">");
editorPane.setEditable(false);
f.add(editorPane);
f.setSize(220, 240);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setVisible(true);
});
}
}
Use below test program and attached image to reproduce the issue.
------------------------------------
ImageTest.java
============
import javax.swing.*;
public class ImageTest {
private static final String ABSOLUTE_FILE_PATH =
"c:\\ws\\Test\\src\\test\\circle.png";
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame f = new JFrame();
// the following line is expected to work in the same
//way
//as the next (commented) line, as the image has aspect ratio 1:1
JEditorPane editorPane = new JEditorPane("text/html",
"<img width=\"200\" src=\"file:///" + ABSOLUTE_FILE_PATH + "\">");
// JEditorPane editorPane = new JEditorPane("text/html",
//"<img width=\"200\" height=\"200\" src=\"file:///" + ABSOLUTE_FILE_PATH +
//"\">");
editorPane.setEditable(false);
f.add(editorPane);
f.setSize(220, 240);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setVisible(true);
});
}
}
- backported by
-
JDK-8207291 Aspect ratio is not maintained when Image is scaled in JEditorPane
- Resolved
-
JDK-8207498 Aspect ratio is not maintained when Image is scaled in JEditorPane
- Resolved
-
JDK-8207609 Aspect ratio is not maintained when Image is scaled in JEditorPane
- Resolved
- relates to
-
JDK-8195095 Images are not scaled correctly in JEditorPane
- Resolved
-
JDK-8208638 Instead of circle rendered in appl window, but ellipse is produced JEditor Pane
- Resolved