--- /dev/null
+/* \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.rasterfilter;\r
+\r
+import jp.nyatla.nyartoolkit.NyARException;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.types.NyARBufferType;\r
+import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
+\r
+/**\r
+ * 色調テーブルを使用したフィルターです。\r
+ * 色調テーブルクラスのベースクラスです。\r
+ */\r
+public class NyARRasterFilter_CustomToneTable implements INyARRasterFilter\r
+{\r
+ protected final int[] table=new int[256];\r
+ private IdoFilterImpl _dofilterimpl;\r
+ protected NyARRasterFilter_CustomToneTable(int i_raster_type) throws NyARException\r
+ {\r
+ switch (i_raster_type) {\r
+ case NyARBufferType.INT1D_GRAY_8:\r
+ this._dofilterimpl=new IdoFilterImpl_INT1D_GRAY_8();\r
+ break;\r
+ default:\r
+ throw new NyARException();\r
+ }\r
+ this._dofilterimpl._table_ref=this.table;\r
+ }\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
+ {\r
+ assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
+ this._dofilterimpl.doFilter(i_input,i_output,i_input.getSize());\r
+ }\r
+ \r
+ private abstract class IdoFilterImpl\r
+ {\r
+ public int[] _table_ref;\r
+ public abstract void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException;\r
+ \r
+ }\r
+ private class IdoFilterImpl_INT1D_GRAY_8 extends IdoFilterImpl\r
+ {\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException\r
+ {\r
+ assert( i_input.isEqualBufferType(NyARBufferType.INT1D_GRAY_8));\r
+ \r
+ int[] out_buf = (int[]) i_output.getBuffer();\r
+ int[] in_buf = (int[]) i_input.getBuffer();\r
+ for(int i=i_size.h*i_size.w-1;i>=0;i--)\r
+ {\r
+ out_buf[i]=this._table_ref[in_buf[i]];\r
+ }\r
+ return;\r
+ }\r
+ }\r
+}\r