import java.awt.image.BufferedImage; import java.awt.Graphics2D;
public static BufferedImage combine(BufferedImage source, BufferedImage other, int x, int y, int ox, int oy, int owidth, int oheight, int cx, int cy){ BufferedImage out = new BufferedImage(source.getWidth(), source.getHeight(), source.getType()); Graphics2D g2d = out.createGraphics(); g2d.drawImage(source, 0, 0, null); x -= cx; y -= cy; g2d.drawImage(other, x, y, x + owidth, y + oheight, ox, oy, ox + owidth, oy + oheight, null); g2d.dispose(); return out; } public static BufferedImage combine(BufferedImage source, BufferedImage other, int x, int y, int ox, int oy, int owidth, int oheight){ return combine(source, other, x, y, ox, oy, owidth, oheight, 0, 0); }
修改前
before
以 combine(source, other, 150, 150, 0, 0, 150, 150) 修改後
edit with combine(source, other, 150, 150, 0, 0, 150, 150)
以 combine(source, other, 150, 150, 0, 0, 150, 150, 75, 75) 修改後
edit with combine(source, other, 150, 150, 0, 0, 150, 150, 75, 75)
沒有留言 :
張貼留言