--- old/src/java.desktop/share/classes/java/awt/image/BufferedImage.java 2017-10-31 16:36:41.708760085 +0530 +++ new/src/java.desktop/share/classes/java/awt/image/BufferedImage.java 2017-10-31 16:36:41.476644085 +0530 @@ -30,6 +30,7 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.Transparency; +import java.awt.GraphicsConfiguration; import java.awt.color.ColorSpace; import java.security.AccessController; import java.security.PrivilegedAction; @@ -73,6 +74,7 @@ private final WritableRaster raster; private OffScreenImageSource osis; private Hashtable properties; + private GraphicsConfiguration graphicsConfig = null; /** * Image Type Constants @@ -291,6 +293,22 @@ * Constructs a {@code BufferedImage} of one of the predefined * image types. The {@code ColorSpace} for the image is the * default sRGB space. + * @param config graphics configuration + * @param width width of the created image + * @param height height of the created image + * @param imageType type of the created image + */ + public BufferedImage(GraphicsConfiguration config, int width, + int height, + int imageType) { + this(width, height, imageType); + this.graphicsConfig = config; + } + + /** + * Constructs a {@code BufferedImage} of one of the predefined + * image types. The {@code ColorSpace} for the image is the + * default sRGB space. * @param width width of the created image * @param height height of the created image * @param imageType type of the created image @@ -854,6 +872,15 @@ } /** + * Returns the {@code GraphicsConfiguration}. + * @return the {@code GraphicsConfiguration} of this + * {@code BufferedImage}. + */ + public GraphicsConfiguration getGraphicsConfig() { + return graphicsConfig; + } + + /** * Returns the {@link WritableRaster}. * @return the {@code WritableRaster} of this * {@code BufferedImage}. --- old/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceManager.java 2017-10-31 16:36:42.201006085 +0530 +++ new/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceManager.java 2017-10-31 16:36:41.992902085 +0530 @@ -28,6 +28,7 @@ import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.ImageCapabilities; +import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import sun.java2d.SurfaceData; import sun.java2d.loops.CompositeType; @@ -52,7 +53,14 @@ public BufImgSurfaceManager(BufferedImage bImg) { this.bImg = bImg; - this.sdDefault = BufImgSurfaceData.createData(bImg); + GraphicsConfiguration graphicsConfiguration = bImg.getGraphicsConfig(); + if (graphicsConfiguration != null) { + this.sdDefault = BufImgSurfaceData.createData(bImg, + graphicsConfiguration.getDefaultTransform().getScaleX() + , graphicsConfiguration.getDefaultTransform().getScaleY()); + } else { + this.sdDefault = BufImgSurfaceData.createData(bImg); + } } public SurfaceData getPrimarySurfaceData() { --- old/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java 2017-10-31 16:36:42.705258085 +0530 +++ new/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java 2017-10-31 16:36:42.497154085 +0530 @@ -30,6 +30,7 @@ import java.awt.GraphicsConfiguration; import java.awt.Image; import java.awt.Window; +import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.awt.image.VolatileImage; @@ -38,6 +39,7 @@ import sun.java2d.DestSurfaceProvider; import sun.java2d.InvalidPipeException; import sun.java2d.Surface; +import sun.java2d.pipe.Region; import sun.java2d.pipe.RenderQueue; import sun.java2d.pipe.BufferedContext; import sun.java2d.pipe.hw.AccelGraphicsConfig; @@ -178,14 +180,19 @@ @Override protected Image getBackBuffer(boolean clear) { - int w = window.getWidth(); - int h = window.getHeight(); + GraphicsConfiguration gc = peer.getGraphicsConfiguration(); + AffineTransform transform = gc.getDefaultTransform(); + int w = Region.clipRound( + window.getWidth() * transform.getScaleX()); + int h = Region.clipRound( + window.getHeight() * transform.getScaleY()); if (backBuffer == null || backBuffer.getWidth() != w || backBuffer.getHeight() != h) { flush(); - backBuffer = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE); + backBuffer = new BufferedImage(gc, w, h, BufferedImage + .TYPE_INT_ARGB_PRE); } return clear ? (BufferedImage)clearImage(backBuffer) : backBuffer; }