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; }
/// <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; }
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; }
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); }