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.rasterreader.INyARBufferReader;
\r
35 import jp.nyatla.nyartoolkit.core.rasterreader.NyARBufferReader;
\r
36 import jp.nyatla.nyartoolkit.core.types.*;
\r
38 public final class NyARGrayscaleRaster extends NyARRaster_BasicClass
\r
41 protected int[] _ref_buf;
\r
42 private INyARBufferReader _buffer_reader;
\r
44 public NyARGrayscaleRaster(int i_width, int i_height)
\r
46 super(new NyARIntSize(i_width,i_height));
\r
47 this._ref_buf = new int[i_height*i_width];
\r
48 this._buffer_reader=new NyARBufferReader(this._ref_buf,INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);
\r
50 public INyARBufferReader getBufferReader()
\r
52 return this._buffer_reader;
\r
64 public void getPixelVector4(int x,int y,NyARIntPoint2d o_v)
\r
66 int[] buf=this._ref_buf;
\r
69 o_v.x=buf[idx+1]-buf[idx-1];
\r
70 o_v.y=buf[idx+w]-buf[idx-w];
\r
82 public void getPixelVector8(int x,int y,NyARIntPoint2d o_v)
\r
84 int[] buf=this._ref_buf;
\r
85 NyARIntSize s=this._size;
\r
87 int idx_p1=idx_0+s.w;
\r
88 int idx_m1=idx_0-s.w;
\r
89 int b=buf[idx_m1-1];
\r
90 int d=buf[idx_m1+1];
\r
91 int h=buf[idx_p1-1];
\r
92 int f=buf[idx_p1+1];
\r
93 o_v.x=buf[idx_0+1]-buf[idx_0-1]+(d-b+f-h)/2;
\r
94 o_v.y=buf[idx_p1]-buf[idx_m1]+(f-d+h-b)/2;
\r
97 public void copyFrom(NyARGrayscaleRaster i_input) throws NyARException
\r
99 int[] out_buf = (int[])this._ref_buf;
\r
100 int[] in_buf = (int[]) i_input._ref_buf;
\r
101 System.arraycopy(in_buf,0,out_buf,0,this._size.h*this._size.w);
\r