+/* \r
+ * PROJECT: NyARToolkit(Extension)\r
+ * --------------------------------------------------------------------------------\r
+ * The NyARToolkit is Java edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ * \r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+ * \r
+ * For further information please contact.\r
+ * http://nyatla.jp/nyatoolkit/\r
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.rasterreader;\r
+\r
+import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
+import jp.nyatla.nyartoolkit.core.types.NyARIntPoint2d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
+\r
+public class NyARVectorReader_INT1D_GRAY_8\r
+{\r
+ private int[] _ref_buf;\r
+ private NyARIntSize _ref_size;\r
+ public NyARVectorReader_INT1D_GRAY_8(INyARRaster i_ref_raster)\r
+ {\r
+ assert(i_ref_raster.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);\r
+ this._ref_buf=(int[])(i_ref_raster.getBufferReader().getBuffer());\r
+ this._ref_size=i_ref_raster.getSize();\r
+ }\r
+ /**\r
+ * 4近傍の画素ベクトルを取得します。\r
+ * 0,1,0\r
+ * 1,x,1\r
+ * 0,1,0\r
+ * @param i_raster\r
+ * @param x\r
+ * @param y\r
+ * @param o_v\r
+ */\r
+ public void getPixelVector4(int x,int y,NyARIntPoint2d o_v)\r
+ {\r
+ int[] buf=this._ref_buf;\r
+ int w=this._ref_size.w;\r
+ int idx=w*y+x;\r
+ o_v.x=buf[idx+1]-buf[idx-1];\r
+ o_v.y=buf[idx+w]-buf[idx-w];\r
+ }\r
+ /**\r
+ * 8近傍画素ベクトル\r
+ * 1,2,1\r
+ * 2,x,2\r
+ * 1,2,1\r
+ * @param i_raster\r
+ * @param x\r
+ * @param y\r
+ * @param o_v\r
+ */\r
+ public void getPixelVector8(int x,int y,NyARIntPoint2d o_v)\r
+ {\r
+ int[] buf=this._ref_buf;\r
+ NyARIntSize s=this._ref_size;\r
+ int idx_0 =s.w*y+x;\r
+ int idx_p1=idx_0+s.w;\r
+ int idx_m1=idx_0-s.w;\r
+ int b=buf[idx_m1-1];\r
+ int d=buf[idx_m1+1];\r
+ int h=buf[idx_p1-1];\r
+ int f=buf[idx_p1+1];\r
+ o_v.x=buf[idx_0+1]-buf[idx_0-1]+(d-b+f-h)/2;\r
+ o_v.y=buf[idx_p1]-buf[idx_m1]+(f-d+h-b)/2;\r
+ } \r
+}
\ No newline at end of file