On 07.11.2013 6:01, Jim Graham wrote:
On 11/6/13 5:20 PM, Sergey Bylokhov wrote:
In other words:
package sun.awt.image;
public interface MultiResImage {
public Image getResolutionVariant(float resolution);
}
public class MacImage extends Image implements MultiResImage {
public Image getResolutionVariant(float resolution) {
if (resolution >= 2f && ImageAt2x != null) {
return ImageAt2x;
}
return this;
}
}
SG2D.drawImage() {
if (img instanceof MultiResImage && dest.pixelscale != 1) {
img = ((MultiResImage)
img).getResolutionVariant(dest.pixelscale);
}
}
In this example there is a problem. For example we have 2
BufferedImages/ToolkiImagest A and B; Both wants be scaled perfectly.
- Image A draws to the image B
- Image B draws to the window.
When window is moving from the screen x1 to the screen x2 and back. How
to handle this situation?
In this case getResolutionVariant() can return
Related discussion:
http://mail.openjdk.java.net/pipermail/macosx-port-dev/2013-April/005580.html
http://mail.openjdk.java.net/pipermail/macosx-port-dev/2013-April/005581.html
How does calling getScaledInstance() deal with that? Note the above
was simply to demonstrate the visibility of the interface, not to be a
complete implementation...
For example:
- getScaledInstance() will be called() when image B will be painted to
the window with scale x2.
- Inside B.getScaledInstance() the user can create BufferedImage C
- get graphics from C and set new render hint to IMAGE_SCALING_ON ans
set scalex2.
- Apply to C absolutely the same rendering which was used in B.
- getScaledInstance() will be called for A.
...jim
--
Best regards, Sergey.