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.NyARException;
\r
34 import jp.nyatla.nyartoolkit.core.types.*;
\r
36 public class NyARGrayscaleRaster extends NyARRaster_BasicClass
\r
39 protected Object _buf;
\r
41 * バッファオブジェクトがアタッチされていればtrue
\r
43 protected boolean _is_attached_buffer;
\r
45 public NyARGrayscaleRaster(int i_width, int i_height) throws NyARException
\r
47 super(new NyARIntSize(i_width,i_height),NyARBufferType.INT1D_GRAY_8);
\r
48 if(!initInstance(this._size,NyARBufferType.INT1D_GRAY_8,true)){
\r
49 throw new NyARException();
\r
52 public NyARGrayscaleRaster(int i_width, int i_height,boolean i_is_alloc) throws NyARException
\r
54 super(new NyARIntSize(i_width,i_height),NyARBufferType.INT1D_GRAY_8);
\r
55 if(!initInstance(this._size,NyARBufferType.INT1D_GRAY_8,i_is_alloc)){
\r
56 throw new NyARException();
\r
62 * @param i_raster_type
\r
63 * NyARBufferTypeに定義された定数値を指定してください。
\r
65 * @throws NyARException
\r
67 public NyARGrayscaleRaster(int i_width, int i_height,int i_raster_type,boolean i_is_alloc) throws NyARException
\r
69 super(new NyARIntSize(i_width,i_height),i_raster_type);
\r
70 if(!initInstance(this._size,i_raster_type,i_is_alloc)){
\r
71 throw new NyARException();
\r
74 protected boolean initInstance(NyARIntSize i_size,int i_buf_type,boolean i_is_alloc)
\r
78 case NyARBufferType.INT1D_GRAY_8:
\r
79 this._buf =i_is_alloc?new int[i_size.w*i_size.h]:null;
\r
84 this._is_attached_buffer=i_is_alloc;
\r
87 public Object getBuffer()
\r
92 * インスタンスがバッファを所有するかを返します。
\r
93 * コンストラクタでi_is_allocをfalseにしてラスタを作成した場合、
\r
94 * バッファにアクセスするまえに、バッファの有無をこの関数でチェックしてください。
\r
97 public boolean hasBuffer()
\r
99 return this._buf!=null;
\r
101 public void wrapBuffer(Object i_ref_buf)
\r
103 assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。
\r
104 this._buf=i_ref_buf;
\r