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
7 public class NyARRgbRaster extends NyARRgbRaster_BasicClass
\r
9 protected Object _buf;
\r
10 protected INyARRgbPixelReader _reader;
\r
12 * バッファオブジェクトがアタッチされていればtrue
\r
14 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(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(i_width,i_height,i_raster_type);
\r
43 if(!initInstance(this._size,i_raster_type,true)){
\r
44 throw new NyARException();
\r
48 * Readerとbufferを初期化する関数です。コンストラクタから呼び出します。
\r
49 * 継承クラスでこの関数を拡張することで、対応するバッファタイプの種類を増やせます。
\r
51 * @param i_raster_type
\r
55 protected boolean initInstance(NyARIntSize i_size,int i_raster_type,boolean i_is_alloc)
\r
57 switch(i_raster_type)
\r
59 case NyARBufferType.INT1D_X8R8G8B8_32:
\r
60 this._buf=i_is_alloc?new int[i_size.w*i_size.h]:null;
\r
61 this._reader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32((int[])this._buf,i_size);
\r
63 case NyARBufferType.BYTE1D_B8G8R8X8_32:
\r
64 this._buf=i_is_alloc?new byte[i_size.w*i_size.h*4]:null;
\r
65 this._reader=new NyARRgbPixelReader_BYTE1D_B8G8R8X8_32((byte[])this._buf,i_size);
\r
67 case NyARBufferType.BYTE1D_R8G8B8_24:
\r
68 this._buf=i_is_alloc?new byte[i_size.w*i_size.h*3]:null;
\r
69 this._reader=new NyARRgbPixelReader_BYTE1D_R8G8B8_24((byte[])this._buf,i_size);
\r
71 case NyARBufferType.BYTE1D_B8G8R8_24:
\r
72 this._buf=i_is_alloc?new byte[i_size.w*i_size.h*3]:null;
\r
73 this._reader=new NyARRgbPixelReader_BYTE1D_B8G8R8_24((byte[])this._buf,i_size);
\r
75 case NyARBufferType.BYTE1D_X8R8G8B8_32:
\r
76 this._buf=i_is_alloc?new byte[i_size.w*i_size.h*4]:null;
\r
77 this._reader=new NyARRgbPixelReader_BYTE1D_X8R8G8B8_32((byte[])this._buf,i_size);
\r
79 case NyARBufferType.WORD1D_R5G6B5_16LE:
\r
80 this._buf=i_is_alloc?new short[i_size.w*i_size.h]:null;
\r
81 this._reader=new NyARRgbPixelReader_WORD1D_R5G6B5_16LE((short[])this._buf,i_size);
\r
86 this._is_attached_buffer=i_is_alloc;
\r
89 public INyARRgbPixelReader getRgbPixelReader() throws NyARException
\r
91 return this._reader;
\r
93 public Object getBuffer()
\r
97 public boolean hasBuffer()
\r
99 return this._buf!=null;
\r
101 public void wrapBuffer(Object i_ref_buf) throws NyARException
\r
103 assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。
\r
104 this._buf=i_ref_buf;
\r
105 //ピクセルリーダーの参照バッファを切り替える。
\r
106 this._reader.switchBuffer(i_ref_buf);
\r