import javax.imageio.*;
import groovy.swing.j2d.*
img = ImageIO.read(new File("sample3b.jpg"))
w = img.getWidth()
h = img.getHeight()
println("w:${w}, h:${h}")
gr = new GraphicsRenderer()
gr.renderToFile("sample945a.png", w*2, h*2){
antialias("on")
rect( x: 0, y: 0, width: w, height: h,
borderColor: no){
texturePaint(x: 0, y: 0, image: img )
filters {
grayscale()
}
}
rect( x: w, y: 0, width: w, height: h,
borderColor: no){
texturePaint(x: 0, y: 0, image: img )
filters {
invert()
grayscale()
}
}
rect( x: 0, y: h, width: w, height: h,
borderColor: no){
texturePaint(x: 0, y: 0, image: img )
filters {
invert()
grayscale()
}
}
rect( x: w, y: h, width: w, height: h,
borderColor: no){
texturePaint(x: 0, y: 0, image: img )
filters {
grayscale()
}
}
}
元画像(sample3b.jpg)
出力画像(sample945a.png)
動作環境
Groovy1.6.0, JDK1.6 Update12
関連項目
groovyで画像をグレースケールに変換する
groovyで画像を反転させる
No comments:
Post a Comment