2 * PROJECT: NyARToolkit(Extension)
\r
3 * --------------------------------------------------------------------------------
\r
4 * The NyARToolkit is Java edition ARToolKit class library.
\r
5 * Copyright (C)2008-2009 Ryo Iizuka
\r
7 * This program is free software: you can redistribute it and/or modify
\r
8 * it under the terms of the GNU General Public License as published by
\r
9 * the Free Software Foundation, either version 3 of the License, or
\r
10 * (at your option) any later version.
\r
12 * This program is distributed in the hope that it will be useful,
\r
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 * GNU General Public License for more details.
\r
17 * You should have received a copy of the GNU General Public License
\r
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
20 * For further information please contact.
\r
21 * http://nyatla.jp/nyatoolkit/
\r
22 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
\r
25 package jp.nyatla.nyartoolkit.nyidmarker.data;
\r
27 import jp.nyatla.nyartoolkit.nyidmarker.*;
\r
30 public class NyIdMarkerDataEncoder_RawBit implements INyIdMarkerDataEncoder
\r
32 private final static int _DOMAIN_ID=0;
\r
33 private final static int[] _mod_data={7,31,127,511,2047,4095};
\r
34 public boolean encode(NyIdMarkerPattern i_data,INyIdMarkerData o_dest)
\r
36 final NyIdMarkerData_RawBit dest=(NyIdMarkerData_RawBit)o_dest;
\r
37 if(i_data.ctrl_domain!=_DOMAIN_ID){
\r
41 final int resolution_len=(i_data.model+1);
\r
42 final int packet_length=(resolution_len*resolution_len)/8+1;
\r
44 for(int i=0;i<packet_length;i++){
\r
45 dest.packet[i]=i_data.data[i];
\r
46 sum+=i_data.data[i];
\r
49 sum=sum%_mod_data[i_data.model-2];
\r
51 if(i_data.check!=sum){
\r
54 dest.length=packet_length;
\r
57 public INyIdMarkerData createDataInstance()
\r
59 return new NyIdMarkerData_RawBit();
\r