public void CreateRecord()
        {
            DirectoryInfo directory = new DirectoryInfo("font");
            FileInfo[] allImg = directory.GetFiles("*.p3img");
            List<P3Img> imgInfo = new List<P3Img>();
            foreach (FileInfo single in allImg)
            {
                //跳过这个奇葩文件
                if (single.Name.Equals("ft_gaiji"))
                    continue;

                using (FileStream reader = single.OpenRead())
                {
                    using (BinaryReader br = new BinaryReader(reader))
                    {
                        P3Img p = new P3Img();
                        p.Name = single.Name.Replace(single.Extension, "");
                        reader.Seek(0x14, SeekOrigin.Begin);
                        p.BaseIdentifier = DataConverter.BigEndian.GetInt32(br.ReadBytes(4), 0);
                        reader.Seek(0x90, SeekOrigin.Begin);
                        p.Identifier = DataConverter.BigEndian.GetInt32(br.ReadBytes(4), 0);
                        imgInfo.Add(p);
                    }
                }
            }

            List<string> txts = new List<string>();
            foreach (P3Img s in imgInfo)
            {
                txts.Add(string.Format("{0},{1},{2}", s.Name, s.BaseIdentifier, s.Identifier));
            }

            File.WriteAllLines("p3img.txt", txts.ToArray());
        }
Пример #2
0
        public FontImg()
        {
            Assembly asm = Assembly.GetExecutingAssembly();//读取嵌入式资源

            using (StreamReader s = new StreamReader(asm.GetManifestResourceStream("FontCreator.p3img.txt")))
            {
                while (!s.EndOfStream)
                {
                    string line = s.ReadLine();
                    string[] info = line.Split(new char[] { ',' });
                    P3Img img = new P3Img
                    {
                        Name = info[0],
                        BaseIdentifier = int.Parse(info[1]),
                        Identifier = int.Parse(info[2])
                    };
                    allImgs.Add(img.Name, img);
                }
            }
        }
Пример #3
0
        public FontImg()
        {
            Assembly asm = Assembly.GetExecutingAssembly();//读取嵌入式资源

            using (StreamReader s = new StreamReader(asm.GetManifestResourceStream("FontCreator.p3img.txt")))
            {
                while (!s.EndOfStream)
                {
                    string   line = s.ReadLine();
                    string[] info = line.Split(new char[] { ',' });
                    P3Img    img  = new P3Img
                    {
                        Name           = info[0],
                        BaseIdentifier = int.Parse(info[1]),
                        Identifier     = int.Parse(info[2])
                    };
                    allImgs.Add(img.Name, img);
                }
            }
        }
Пример #4
0
        public void CreateRecord()
        {
            DirectoryInfo directory = new DirectoryInfo("font");

            FileInfo[]   allImg  = directory.GetFiles("*.p3img");
            List <P3Img> imgInfo = new List <P3Img>();

            foreach (FileInfo single in allImg)
            {
                //跳过这个奇葩文件
                if (single.Name.Equals("ft_gaiji"))
                {
                    continue;
                }

                using (FileStream reader = single.OpenRead())
                {
                    using (BinaryReader br = new BinaryReader(reader))
                    {
                        P3Img p = new P3Img();
                        p.Name = single.Name.Replace(single.Extension, "");
                        reader.Seek(0x14, SeekOrigin.Begin);
                        p.BaseIdentifier = DataConverter.BigEndian.GetInt32(br.ReadBytes(4), 0);
                        reader.Seek(0x90, SeekOrigin.Begin);
                        p.Identifier = DataConverter.BigEndian.GetInt32(br.ReadBytes(4), 0);
                        imgInfo.Add(p);
                    }
                }
            }

            List <string> txts = new List <string>();

            foreach (P3Img s in imgInfo)
            {
                txts.Add(string.Format("{0},{1},{2}", s.Name, s.BaseIdentifier, s.Identifier));
            }

            File.WriteAllLines("p3img.txt", txts.ToArray());
        }