import javax.imageio.*;
import groovy.swing.j2d.*
img = ImageIO.read(new File("sf.jpg"))
gr = new GraphicsRenderer()
gr.renderToFile("sample948a.png", img.width, img.height){
 antialias("on")
 rect( x: 0, y: 0,
   width: img.width, height: img.height,
   borderColor: no){
   texturePaint(x: 0, y: 0, image: img )
   filters {
     grayscale()
   }
 }
 ellipse( cx: img.width/2, cy: img.height/2,
   radiusx: img.width/2, radiusy: img.height/2,
   borderColor: no){
   texturePaint(x: 0, y: 0, image: img )
 }
}
元画像(sf.jpg)
出力画像(sample948a.png)

動作環境
Groovy1.6.0, JDK1.6 Update12
 
No comments:
Post a Comment