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
37 * このクラスは、指定形式のバッファを持つインスタンスを生成します。
\r
38 * <p>対応しているバッファ形式は以下の通りです。
\r
40 * <li>{@link NyARBufferType#INT1D}
\r
41 * <li>{@link NyARBufferType#INT1D_X8R8G8B8_32}
\r
46 public class NyARRaster extends NyARRaster_BasicClass
\r
49 protected Object _buf;
\r
50 /** バッファオブジェクトがアタッチされていればtrue*/
\r
51 protected boolean _is_attached_buffer;
\r
54 * 画像のサイズパラメータとバッファ形式を指定して、インスタンスを生成します。
\r
59 * @param i_buffer_type
\r
61 * {@link NyARBufferType}に定義された定数値を指定してください。
\r
62 * 指定できる値は、クラスの説明を見てください。
\r
64 * バッファを外部参照にするかのフラグ値。
\r
65 * trueなら内部バッファ、falseなら外部バッファを使用します。
\r
66 * falseの場合、初期のバッファはnullになります。インスタンスを生成したのちに、{@link #wrapBuffer}を使って割り当ててください。
\r
67 * @throws NyARException
\r
69 public NyARRaster(int i_width, int i_height,int i_buffer_type,boolean i_is_alloc) throws NyARException
\r
71 super(i_width,i_height,i_buffer_type);
\r
72 if(!initInstance(this._size,i_buffer_type,i_is_alloc)){
\r
73 throw new NyARException();
\r
79 * 画像のサイズパラメータとバッファ形式を指定して、インスタンスを生成します。
\r
84 * @param i_buffer_type
\r
86 * {@link NyARBufferType}に定義された定数値を指定してください。
\r
87 * 指定できる値は、クラスの説明を見てください。
\r
88 * @throws NyARException
\r
90 public NyARRaster(int i_width, int i_height,int i_buffer_type) throws NyARException
\r
92 super(i_width,i_height,i_buffer_type);
\r
93 if(!initInstance(this._size,i_buffer_type,true)){
\r
94 throw new NyARException();
\r
99 * このクラスの初期化シーケンスです。コンストラクタから呼び出します。
\r
102 * @param i_buf_type
\r
104 * @param i_is_alloc
\r
107 * 初期化に成功するとtrueを返します。
\r
109 protected boolean initInstance(NyARIntSize i_size,int i_buf_type,boolean i_is_alloc)
\r
113 case NyARBufferType.INT1D:
\r
114 case NyARBufferType.INT1D_X8R8G8B8_32:
\r
115 this._buf=i_is_alloc?new int[i_size.w*i_size.h]:null;
\r
121 this._is_attached_buffer=i_is_alloc;
\r
125 * この関数は、ラスタのバッファへの参照値を返します。
\r
126 * バッファの形式は、コンストラクタに指定した形式と同じです。
\r
128 public Object getBuffer()
\r
133 * インスタンスがバッファを所有するかを返します。
\r
134 * コンストラクタでi_is_allocをfalseにしてラスタを作成した場合、
\r
135 * バッファにアクセスするまえに、バッファの有無をこの関数でチェックしてください。
\r
137 public boolean hasBuffer()
\r
139 return this._buf!=null;
\r
142 * この関数は、ラスタに外部参照バッファをセットします。
\r
143 * 外部参照バッファを持つインスタンスでのみ使用できます。内部参照バッファを持つインスタンスでは使用できません。
\r
145 public void wrapBuffer(Object i_ref_buf) throws NyARException
\r
147 assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。
\r
148 this._buf=i_ref_buf;
\r