예제 #1
0
파일: potLoader.cs 프로젝트: htb012/ssoawfc
 public override CharPattern next()
 {
     CharPattern pat = new CharPattern();
     if (fs.Position >= length)
     {
         return null;
     }
     sampleSize = br.ReadInt16();
     br.ReadBytes(4);
     pat.strokeNum = (ushort)br.ReadInt16();
     Stroke stroke = new Stroke();
     short x, y;
     do
     {
         x = br.ReadInt16();
         y = br.ReadInt16();
         if (x != -1)
         {
             stroke.points.Add(new point(x, y));
         }
         else
         {
             if (y != -1)
             {
                 if (stroke.points.Count <= 1) {
                     Console.WriteLine("have point stroke!");
                 }
                 pat.strokes.Add(stroke);
                 stroke = new Stroke();
             }
         }
     } while (y != -1);
     return pat;
 }
예제 #2
0
        /// <summary>
        /// 从一个binaryReader中读取一个文件内的一个Pot pattern
        /// </summary>
        /// <param name="br"></param>
        /// <returns></returns>
        public CharPattern getPotPattern(BinaryReader br) {
            CharPattern pat = new CharPattern();
            pat.sampleSize = br.ReadUInt16();
            byte[] bytes = br.ReadBytes(4);
            //数组反转(重点,查看邮件记录20120417)
            Array.Reverse(bytes);
            int[] tagCodeInfo = getTagCodeInfo(bytes);
            char[] c = gb2312.GetChars(bytes, tagCodeInfo[0], tagCodeInfo[1]);
            if (tagCodeInfo[1] == 1)
            {
                c = ToSBC(c);
            }
            pat.tagCode = new string(c);

            //Console.WriteLine(new String(pat.TagCode));
            //br.ReadBytes(2);
            pat.strokeNum = br.ReadUInt16();
            Stroke stroke = new Stroke();
            short x, y;
            do
            {
                x = br.ReadInt16();
                y = br.ReadInt16();
                if (x != -1)
                {
                    stroke.points.Add(new point(x, y));
                }
                else
                {
                    if (y == 0)
                    {
                        if (stroke.points.Count > 1) {
                            pat.strokes.Add(stroke);
                        }
                        stroke = new Stroke();
                    }
                }
            } while (y != -1);
            return pat;
        }
예제 #3
0
        public CharPattern nextPattern()
        {
            if (!sr.EndOfStream)
            {
                string str;
                while (Convert.ToChar(sr.Peek()) != '[')
                {
                    sr.ReadLine();
                }
                str = sr.ReadLine().Trim();
                CharPattern pat = new CharPattern();
                pat.tagCode = str.Substring(1, 1);
                Stroke stroke = new Stroke();
                ushort strokeNum=0;
                while (!sr.EndOfStream && (Convert.ToChar(sr.Peek()) != '['))
                {
                    str = sr.ReadLine().Trim();
                    string[] data = null;
                    if (str.Contains('\t'))
                    {
                        data = str.Split('\t');
                    }
                    else {
                        data = str.Split(' ');
                    }

                    short penState = Int16.Parse(data[0]);
                    short x = Int16.Parse(data[1]);
                    short y = Int16.Parse(data[2]);
                    stroke.points.Add(new point(x,y));
                    if (penState == tehonPattern.UP)
                    {
                        pat.strokes.Add(stroke);
                        stroke = new Stroke();
                        strokeNum++;
                    }
                }
                pat.strokeNum = strokeNum;
                return pat;
            }
            return null;
        }
예제 #4
0
파일: test.cs 프로젝트: htb012/ssoawfc
        public static void tt() {
            CharPattern pat = new CharPattern();
            Stroke stroke = new Stroke();
            stroke.points.Add(new point(0, 0));

            stroke.points.Add(new point(400, 400));
            pat.strokes.Add(stroke);

            point p = POTTool.getOnlineCenter(pat);
        }