src/share/classes/sun/java2d/pipe/DrawImage.java
Print this page
@@ -25,30 +25,26 @@
package sun.java2d.pipe;
import java.awt.AlphaComposite;
import java.awt.Color;
-import java.awt.Graphics2D;
import java.awt.Image;
-import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
-import java.awt.image.DirectColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.IndexColorModel;
import java.awt.image.Raster;
import java.awt.image.VolatileImage;
-import java.awt.image.WritableRaster;
-import java.awt.image.ImagingOpException;
import sun.awt.SunHints;
import sun.awt.image.ImageRepresentation;
+import sun.awt.image.SurfaceManager;
import sun.awt.image.ToolkitImage;
import sun.java2d.InvalidPipeException;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import sun.java2d.loops.Blit;
@@ -321,19 +317,21 @@
* color with a SrcOver operation, otherwise make a SrcNoEa copy.
*/
BufferedImage makeBufferedImage(Image img, Color bgColor, int type,
int sx1, int sy1, int sx2, int sy2)
{
- BufferedImage bimg = new BufferedImage(sx2-sx1, sy2-sy1, type);
- Graphics2D g2d = bimg.createGraphics();
+ final int width = sx2 - sx1;
+ final int height = sy2 - sy1;
+ final BufferedImage bimg = new BufferedImage(width, height, type);
+ final SunGraphics2D g2d = (SunGraphics2D) bimg.createGraphics();
g2d.setComposite(AlphaComposite.Src);
if (bgColor != null) {
g2d.setColor(bgColor);
- g2d.fillRect(0, 0, sx2-sx1, sy2-sy1);
+ g2d.fillRect(0, 0, width, height);
g2d.setComposite(AlphaComposite.SrcOver);
}
- g2d.drawImage(img, -sx1, -sy1, null);
+ g2d.copyImage(img, 0, 0, sx1, sy1, width, height, null, null);
g2d.dispose();
return bimg;
}
protected void renderImageXform(SunGraphics2D sg, Image img,
@@ -735,12 +733,13 @@
double m00 = (double)(dx2-dx1)/(sx2-sx1);
double m11 = (double)(dy2-dy1)/(sy2-sy1);
atfm.scale(m00, m11);
atfm.translate(srcX-sx1, srcY-sy1);
- int imgW = img.getWidth(null);
- int imgH = img.getHeight(null);
+ final int scale = SurfaceManager.getImageScale(img);
+ final int imgW = img.getWidth(null) * scale;
+ final int imgH = img.getHeight(null) * scale;
srcW += srcX;
srcH += srcY;
// Make sure we are not out of bounds
if (srcW > imgW) {
srcW = imgW;