|
Revision 5723, 0.9 kB
(checked in by ryugate, 5 years ago)
|
|
/scala/sandbox/src/jp/ryugate/excel/*.scala: modules for Excel
/scala/sandbox/src/jp/ryugate/image/*.scala: modules for Java2D
/scala/sandbox/src/jp/ryugate/video/Timecode*.scala: modules for Video Timecode
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | package jp.ryugate.image |
|---|
| 2 | |
|---|
| 3 | import java.io.Serializable |
|---|
| 4 | import java.io.File |
|---|
| 5 | import java.awt.image.BufferedImage |
|---|
| 6 | import java.awt.Color |
|---|
| 7 | import javax.imageio.ImageIO |
|---|
| 8 | |
|---|
| 9 | class Image(w:int, h:int, img:BufferedImage) { |
|---|
| 10 | def this(w:int,h:int) = this(w,h,new BufferedImage(w,h, BufferedImage.TYPE_INT_RGB)) |
|---|
| 11 | def this(w:int,h:int, t:int) = this(w,h,new BufferedImage(w,h, t)) |
|---|
| 12 | |
|---|
| 13 | def process(f:(Graphics => Unit)) = { |
|---|
| 14 | val g = img.createGraphics |
|---|
| 15 | g.setBackground(Color.BLACK) |
|---|
| 16 | g.setColor(Color.WHITE) |
|---|
| 17 | f(new Graphics(g)) |
|---|
| 18 | this |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | def clearBackground(c:Color) = { |
|---|
| 22 | val g = img.createGraphics |
|---|
| 23 | g.setBackground(c) |
|---|
| 24 | g.clearRect(0,0,w,h) |
|---|
| 25 | this |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | def write(ext:String, file:File) = ImageIO.write(img, ext, file) |
|---|
| 29 | |
|---|
| 30 | def width = w |
|---|
| 31 | def height = h |
|---|
| 32 | def image = img |
|---|
| 33 | |
|---|
| 34 | def getData = img.getData |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | object Image { |
|---|
| 38 | def TYPE_INT_RGB = BufferedImage.TYPE_INT_RGB |
|---|
| 39 | } |
|---|