2 * PROJECT: NyARToolkit
\r
3 * --------------------------------------------------------------------------------
\r
4 * This work is based on the original ARToolKit developed by
\r
7 * HITLab, University of Washington, Seattle
\r
8 * http://www.hitl.washington.edu/artoolkit/
\r
10 * The NyARToolkit is Java edition ARToolKit class library.
\r
11 * Copyright (C)2008-2009 Ryo Iizuka
\r
13 * This program is free software: you can redistribute it and/or modify
\r
14 * it under the terms of the GNU General Public License as published by
\r
15 * the Free Software Foundation, either version 3 of the License, or
\r
16 * (at your option) any later version.
\r
18 * This program is distributed in the hope that it will be useful,
\r
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
21 * GNU General Public License for more details.
\r
23 * You should have received a copy of the GNU General Public License
\r
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
26 * For further information please contact.
\r
27 * http://nyatla.jp/nyatoolkit/
\r
28 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
\r
31 package jp.nyatla.nyartoolkit.core.raster;
\r
33 import jp.nyatla.nyartoolkit.core.types.*;
\r
34 import jp.nyatla.nyartoolkit.*;
\r
36 public class NyARBinRaster extends NyARRaster_BasicClass
\r
38 protected Object _buf;
\r
40 * バッファオブジェクトがアタッチされていればtrue
\r
42 protected boolean _is_attached_buffer;
\r
47 * @param i_raster_type
\r
48 * NyARBufferTypeに定義された定数値を指定してください。
\r
50 * @throws NyARException
\r
52 public NyARBinRaster(int i_width, int i_height,int i_raster_type,boolean i_is_alloc) throws NyARException
\r
54 super(new NyARIntSize(i_width,i_height),i_raster_type);
\r
55 if(!initInstance(this._size,i_raster_type,i_is_alloc)){
\r
56 throw new NyARException();
\r
59 public NyARBinRaster(int i_width, int i_height,boolean i_is_alloc) throws NyARException
\r
61 super(new NyARIntSize(i_width,i_height),NyARBufferType.INT1D_BIN_8);
\r
62 if(!initInstance(this._size,NyARBufferType.INT1D_BIN_8,i_is_alloc)){
\r
63 throw new NyARException();
\r
66 public NyARBinRaster(int i_width, int i_height) throws NyARException
\r
68 super(new NyARIntSize(i_width,i_height),NyARBufferType.INT1D_BIN_8);
\r
69 if(!initInstance(this._size,NyARBufferType.INT1D_BIN_8,true)){
\r
70 throw new NyARException();
\r
73 protected boolean initInstance(NyARIntSize i_size,int i_buf_type,boolean i_is_alloc)
\r
77 case NyARBufferType.INT1D_BIN_8:
\r
78 this._buf = i_is_alloc?new int[i_size.w*i_size.h]:null;
\r
83 this._is_attached_buffer=i_is_alloc;
\r
86 public Object getBuffer()
\r
91 * インスタンスがバッファを所有するかを返します。
\r
92 * コンストラクタでi_is_allocをfalseにしてラスタを作成した場合、
\r
93 * バッファにアクセスするまえに、バッファの有無をこの関数でチェックしてください。
\r
96 public boolean hasBuffer()
\r
98 return this._buf!=null;
\r
100 public void wrapBuffer(Object i_ref_buf)
\r
102 assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。
\r
103 this._buf=i_ref_buf;
\r