import java.awt.* import java.awt.image.* import java.awt.geom.* import java.io.* import javax.imageio.* // 指定色の枠を描画する def img = ImageIO.read(new File("sf2.jpg")) def bwidth = 10 def img2 = new BufferedImage( img.getWidth()+bwidth*2, img.getHeight()+bwidth*2, BufferedImage.TYPE_INT_ARGB ) def gr = img2.createGraphics() gr.setColor(new Color(0xccddff)) def rect = new Rectangle2D.Double( 0.0, 0.0, img2.getWidth()-1, img2.getHeight()-1) gr.fill(rect) gr.drawImage(img, bwidth, bwidth, null) gr.dispose() ImageIO.write(img2, "png", new File("border.png"))元画像 出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment