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.rasterfilter;
\r
33 import jp.nyatla.nyartoolkit.NyARException;
\r
34 import jp.nyatla.nyartoolkit.core.raster.INyARRaster;
\r
35 import jp.nyatla.nyartoolkit.core.types.NyARIntSize;
\r
41 public class NyARRasterOperator_Mul
\r
43 private IdoFilterImpl _dofilterimpl;
\r
44 public NyARRasterOperator_Mul(int i_raster_type) throws NyARException
\r
46 switch (i_raster_type) {
\r
47 case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:
\r
48 this._dofilterimpl=new IdoFilterImpl_INT1D_GRAY_8();
\r
51 throw new NyARException();
\r
55 public void doFilter(INyARRaster i_input_a,INyARRaster i_input_b, INyARRaster i_output) throws NyARException
\r
57 assert (i_input_a.getSize().isEqualSize(i_output.getSize()) == true);
\r
58 assert (i_input_b.getSize().isEqualSize(i_output.getSize()) == true);
\r
59 this._dofilterimpl.doFilter(i_input_a,i_input_b,i_output,i_output.getSize());
\r
62 abstract class IdoFilterImpl
\r
65 public abstract void doFilter(INyARRaster i_input_a,INyARRaster i_input_b,INyARRaster i_output,NyARIntSize i_size) throws NyARException;
\r
68 class IdoFilterImpl_INT1D_GRAY_8 extends IdoFilterImpl
\r
70 public void doFilter(INyARRaster i_input_a,INyARRaster i_input_b,INyARRaster i_output,NyARIntSize i_size) throws NyARException
\r
72 assert(i_input_a.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));
\r
73 assert(i_input_b.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));
\r
74 assert(i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));
\r
76 int[] out_buf = (int[]) i_output.getBuffer();
\r
77 int[] in_buf1 = (int[]) i_input_a.getBuffer();
\r
78 int[] in_buf2 = (int[]) i_input_b.getBuffer();
\r
79 for(int i=i_size.h*i_size.w-1;i>=0;i--)
\r
81 out_buf[i]=(in_buf1[i]*in_buf2[i])>>8;
\r