2742 0, 0, 2743 null); 2744 } 2745 2746 // Now we have a BufferedImage starting at (0, 0) 2747 // with the same contents that started at (minX, minY) 2748 // in raster. So we must draw the BufferedImage with a 2749 // translation of (minX, minY). 2750 AffineTransform transXform = (AffineTransform)xform.clone(); 2751 transXform.translate(minX, minY); 2752 2753 ColorModel cm = img.getColorModel(); 2754 BufferedImage bufImg = new BufferedImage(cm, 2755 wRaster, 2756 cm.isAlphaPremultiplied(), 2757 null); 2758 drawImage(bufImg, transXform, null); 2759 } 2760 2761 /** 2762 * Intersects <code>destRect</code> with <code>clip</code> and 2763 * overwrites <code>destRect</code> with the result. 2764 * Returns false if the intersection was empty, true otherwise. 2765 */ 2766 private boolean clipTo(Rectangle destRect, Rectangle clip) { 2767 int x1 = Math.max(destRect.x, clip.x); 2768 int x2 = Math.min(destRect.x + destRect.width, clip.x + clip.width); 2769 int y1 = Math.max(destRect.y, clip.y); 2770 int y2 = Math.min(destRect.y + destRect.height, clip.y + clip.height); 2771 if (((x2 - x1) < 0) || ((y2 - y1) < 0)) { 2772 destRect.width = -1; // Set both just to be safe 2773 destRect.height = -1; 2774 return false; 2775 } else { 2776 destRect.x = x1; 2777 destRect.y = y1; 2778 destRect.width = x2 - x1; 2779 destRect.height = y2 - y1; 2780 return true; 2781 } 2782 } 2783 | 2742 0, 0, 2743 null); 2744 } 2745 2746 // Now we have a BufferedImage starting at (0, 0) 2747 // with the same contents that started at (minX, minY) 2748 // in raster. So we must draw the BufferedImage with a 2749 // translation of (minX, minY). 2750 AffineTransform transXform = (AffineTransform)xform.clone(); 2751 transXform.translate(minX, minY); 2752 2753 ColorModel cm = img.getColorModel(); 2754 BufferedImage bufImg = new BufferedImage(cm, 2755 wRaster, 2756 cm.isAlphaPremultiplied(), 2757 null); 2758 drawImage(bufImg, transXform, null); 2759 } 2760 2761 /** 2762 * Intersects {@code destRect} with {@code clip} and 2763 * overwrites {@code destRect} with the result. 2764 * Returns false if the intersection was empty, true otherwise. 2765 */ 2766 private boolean clipTo(Rectangle destRect, Rectangle clip) { 2767 int x1 = Math.max(destRect.x, clip.x); 2768 int x2 = Math.min(destRect.x + destRect.width, clip.x + clip.width); 2769 int y1 = Math.max(destRect.y, clip.y); 2770 int y2 = Math.min(destRect.y + destRect.height, clip.y + clip.height); 2771 if (((x2 - x1) < 0) || ((y2 - y1) < 0)) { 2772 destRect.width = -1; // Set both just to be safe 2773 destRect.height = -1; 2774 return false; 2775 } else { 2776 destRect.x = x1; 2777 destRect.y = y1; 2778 destRect.width = x2 - x1; 2779 destRect.height = y2 - y1; 2780 return true; 2781 } 2782 } 2783 |