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)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt4CDOW4qxIjrvQ-zGzbkt7GSNUcQ7V1blh1Veda05pHXyb-SQPb1lizOTe2w0Bn6mVGlPttCQFkEms_h1vMzpyLUs3KFHkfPKumjU6f2tXOPIfMfR60iu0_BJSNwF741WtaBH/s320/sample3b.jpg)
出力画像(sample945a.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHbtz4z0PAWekJGbXOhMzdDwJuIBp-r9XrW7EA5iDogC8FDECAJ_DPYaMCNqs2mHnZiGEoYlnWTijeTFU8TV0o7XQ7kEN72EYDqt8Ksz_PTO3mk5vBzqPyj9F7Sr06gzN8A1N_/s320/sample945a.png)
動作環境
Groovy1.6.0, JDK1.6 Update12
関連項目
groovyで画像をグレースケールに変換する
groovyで画像を反転させる
No comments:
Post a Comment