Пример #1
0
        private void ReadFNMP(string filename)
        {
            using (StreamReader sr = new StreamReader(new FileStream(filename, FileMode.Open)))
            {
                while (sr.EndOfStream == false)
                {
                    string str = sr.ReadLine();

                    int    Index = Convert.ToInt32(str.Substring(0, str.IndexOf('=')));
                    string Char  = str.Substring(str.IndexOf('=') + 1);
                    if (Char.Length > 3)
                    {
                        Char = Char.Substring(0, 3);
                    }

                    FnMpData fnmp = List.FirstOrDefault(x => x.Index == Index);
                    if (fnmp == null)
                    {
                        List.Add(new FnMpData {
                            Index = Index, Char = Char
                        });
                    }
                    else
                    {
                        fnmp.Char = Char;
                    }
                }
            }
        }
Пример #2
0
        private void ReadFONT(FileStructure.FNT.FNT FNT)
        {
            Height  = FNT.Header.Glyphs.Size1;
            Width   = FNT.Header.Glyphs.Size2;
            Palette = FNT.Palette.Pallete;
            if (FNT.Header.Glyphs.BitsPerPixel == 4)
            {
                PixelFormat = PixelFormats.Indexed4;
            }
            else if (FNT.Header.Glyphs.BitsPerPixel == 8)
            {
                PixelFormat = PixelFormats.Indexed8;
            }
            else
            {
                throw new Exception("ReadFONT Error: unknown PixelFormat");
            }

            var DecList = FNT.Compressed.GetDecompressedData();

            if (FNT.Header.Glyphs.BitsPerPixel == 4)
            {
                Util.ReverseByteInList(DecList);
            }

            for (int i = 0; i < DecList.Count; i++)
            {
                FnMpData fnmp = List.FirstOrDefault(x => x.Index == i + 32);
                if (fnmp == null)
                {
                    List.Add(new FnMpData {
                        Index = i + 32, Char = "", Cut = FNT.WidthTable[i] == null ? new VerticalCut(0, (byte)Width) : FNT.WidthTable[i].Value, Image_data = DecList[i]
                    });
                }
                else
                {
                    fnmp.Cut        = FNT.WidthTable[i] == null ? new VerticalCut(0, (byte)Width) : FNT.WidthTable[i].Value;
                    fnmp.Image_data = DecList[i];
                }
            }
        }
Пример #3
0
        public byte[] GetByte(string Char)
        {
            if (Char != "")
            {
                FnMpData fnmp = List.FirstOrDefault(x => x.Char == Char);

                if (fnmp != null)
                {
                    if (fnmp.Index < 0x80)
                    {
                        return(new byte[] { (byte)fnmp.Index });
                    }
                    else
                    {
                        byte byte2 = Convert.ToByte((fnmp.Index - 0x20) % 0x80);
                        byte byte1 = Convert.ToByte(((fnmp.Index - 0x20 - byte2) / 0x80) + 0x81);

                        return(new byte[] { byte1, byte2 });
                    }
                }
            }
            return(new byte[0]);
        }
Пример #4
0
        public string GetChar(int index)
        {
            FnMpData fnmp = List.FirstOrDefault(x => x.Index == index);

            if (fnmp == null)
            {
                return("<NCHAR>");
            }
            else
            {
                if (fnmp.Char.Length == 0)
                {
                    return("<CHAR>");
                }
                else if (fnmp.Char.Length == 1)
                {
                    return(fnmp.Char);
                }
                else
                {
                    return("<" + fnmp.Char + ">");
                }
            }
        }