1 package jp.nyatla.nyartoolkit.core.raster.rgb;
\r
3 import jp.nyatla.nyartoolkit.core.rasterreader.*;
\r
4 import jp.nyatla.nyartoolkit.core.types.*;
\r
5 import jp.nyatla.nyartoolkit.*;
\r
6 import jp.nyatla.nyartoolkit.core.raster.*;
\r
8 public class NyARRgbRaster extends NyARRgbRaster_BasicClass
\r
10 protected Object _buf;
\r
11 protected INyARRgbPixelReader _reader;
\r
13 * バッファオブジェクトがアタッチされていればtrue
\r
15 protected boolean _is_attached_buffer;
\r
20 * @param i_raster_type
\r
21 * NyARBufferTypeに定義された定数値を指定してください。
\r
23 * @throws NyARException
\r
25 public NyARRgbRaster(int i_width, int i_height,int i_raster_type,boolean i_is_alloc) throws NyARException
\r
27 super(new NyARIntSize(i_width,i_height),i_raster_type);
\r
28 if(!initInstance(this._size,i_raster_type,i_is_alloc)){
\r
29 throw new NyARException();
\r
36 * @param i_raster_type
\r
37 * NyARBufferTypeに定義された定数値を指定してください。
\r
38 * @throws NyARException
\r
40 public NyARRgbRaster(int i_width, int i_height,int i_raster_type) throws NyARException
\r
42 super(new NyARIntSize(i_width,i_height),i_raster_type);
\r
43 if(!initInstance(this._size,i_raster_type,true)){
\r
44 throw new NyARException();
\r
47 protected boolean initInstance(NyARIntSize i_size,int i_raster_type,boolean i_is_alloc)
\r
49 switch(i_raster_type)
\r
51 case NyARBufferType.INT1D_X8R8G8B8_32:
\r
52 this._buf=i_is_alloc?new int[i_size.w*i_size.h]:null;
\r
53 this._reader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32((int[])this._buf,i_size);
\r
55 case NyARBufferType.BYTE1D_B8G8R8X8_32:
\r
56 this._buf=i_is_alloc?new byte[i_size.w*i_size.h*4]:null;
\r
57 this._reader=new NyARRgbPixelReader_BYTE1D_B8G8R8X8_32((byte[])this._buf,i_size);
\r
59 case NyARBufferType.BYTE1D_R8G8B8_24:
\r
60 this._buf=i_is_alloc?new byte[i_size.w*i_size.h*3]:null;
\r
61 this._reader=new NyARRgbPixelReader_BYTE1D_R8G8B8_24((byte[])this._buf,i_size);
\r
66 this._is_attached_buffer=i_is_alloc;
\r
69 public INyARRgbPixelReader getRgbPixelReader() throws NyARException
\r
71 return this._reader;
\r
73 public Object getBuffer()
\r
77 public boolean hasBuffer()
\r
79 return this._buf!=null;
\r
81 public void wrapBuffer(Object i_ref_buf) throws NyARException
\r
83 assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。
\r
84 this._buf=i_ref_buf;
\r
85 //ピクセルリーダーの参照バッファを切り替える。
\r
86 this._reader.switchBuffer(i_ref_buf);
\r