<AWT Dev> [8] Review request for 8011059 [macosx] Make JDK demos look perfect on retina displays
Alexander Scherbatiy
alexandr.scherbatiy at oracle.com
Tue Oct 22 02:31:51 PDT 2013
Hello,
Could you review the fix:
bug: https://bugs.openjdk.java.net/browse/JDK-8011059
webrev: http://cr.openjdk.java.net/~alexsch/8011059/webrev.00
The IMAGE_SCALING rendering hint is added to the RenderingHints class.
Enabling the image scaling rendering hint forces the SunGraphics2D to
use getScaledInstance(width, height, hints) method
from Image class with SCALE_DEFAULT hint.
By default the image scaling rendering hint is enabled on HiDPI
display and disabled for standard displays.
User can override the getScaledInstance(width, height, hints) method
and return necessary high resolution image
according to the given image width and height.
For example:
---------------------
final Image highResolutionImage =
new BufferedImage(2 * WIDTH, 2 * HEIGHT,
BufferedImage.TYPE_INT_RGB);
Image image = new BufferedImage(WIDTH, HEIGHT,
BufferedImage.TYPE_INT_RGB) {
@Override
public Image getScaledInstance(int width, int height, int
hints) {
if ((hints & Image.SCALE_DEFAULT) != 0) {
return (width <= WIDTH && height <= HEIGHT)
? this : highResolutionImage;
}
return super.getScaledInstance(width, height, hints);
}
};
---------------------
The LWCToolkit and ToolkitImage classes are patched to automatically
get provided image at 2x.ext images on MacOSX.
There are no significant changes in the Java2D demo to make it look
perfect on Retina displays.
It needs only to put necessary images with the @2x postfix and they
will be automatically drawn.
Thanks,
Alexandr.
More information about the awt-dev
mailing list