1 package jp.nyatla.utils.j2se;
\r
3 import java.awt.Color;
\r
4 import java.awt.image.*;
\r
5 import jp.nyatla.nyartoolkit.*;
\r
6 import jp.nyatla.nyartoolkit.core.raster.rgb.*;
\r
7 import jp.nyatla.nyartoolkit.core.raster.*;
\r
8 import jp.nyatla.nyartoolkit.core.rasterreader.*;
\r
10 public class BufferedImageSink extends BufferedImage
\r
12 public BufferedImageSink(int i_width,int i_height)
\r
14 super(i_width,i_height,TYPE_INT_RGB);
\r
17 * i_inの内容を、このイメージにコピーします。
\r
19 * @throws NyARException
\r
21 public void copyFromRaster(INyARRgbRaster i_in) throws NyARException
\r
23 assert i_in.getSize().isEqualSize(this.getWidth(), this.getHeight());
\r
26 INyARRgbPixelReader reader=i_in.getRgbPixelReader();
\r
27 int[] rgb=new int[3];
\r
29 for(int y=this.getHeight()-1;y>=0;y--){
\r
30 for(int x=this.getWidth()-1;x>=0;x--){
\r
31 reader.getPixel(x,y,rgb);
\r
32 this.setRGB(x,y,(rgb[0]<<16)|(rgb[1]<<8)|rgb[2]);
\r
40 * @throws NyARException
\r
42 public void copyFromRaster(INyARRaster i_in) throws NyARException
\r
44 assert i_in.getSize().isEqualSize(this.getWidth(), this.getHeight());
\r
45 if(i_in.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8))
\r
47 final int[] buf=(int[])i_in.getBufferReader().getBuffer();
\r
48 final int w=this.getWidth();
\r
49 final int h=this.getHeight();
\r
50 for(int y=h-1;y>=0;y--){
\r
51 for(int x=w-1;x>=0;x--){
\r
52 this.setRGB(x, y,buf[x+y*w]==0?0:0xffffff);
\r
59 * i_outへこのイメージを出力します。
\r
62 * @throws NyARException
\r
64 public void copyToRaster(INyARRgbRaster i_out) throws NyARException
\r
66 assert i_out.getSize().isEqualSize(this.getWidth(), this.getHeight());
\r
69 INyARRgbPixelReader reader=i_out.getRgbPixelReader();
\r
70 int[] rgb=new int[3];
\r
71 for(int y=this.getHeight()-1;y>=0;y--){
\r
72 for(int x=this.getWidth()-1;x>=0;x--){
\r
73 int pix=this.getRGB(x, y);
\r
74 rgb[0]=(pix>>16)&0xff;
\r
75 rgb[1]=(pix>>8)&0xff;
\r
77 reader.setPixel(x,y,rgb);
\r