Beispiel #1
0
        public XF(Stream input)
        {
            using (var br = new BinaryReaderX(input))
            {
                xpck = new XPCK(input);

                //get xi image to bmp
                xi  = new IMGC(xpck.Files[0].FileData);
                bmp = xi.Image;

                //decompress fnt.bin
                var tempCharSizeInfo = new List <CharSizeInfo>();
                using (var fntR = new BinaryReaderX(xpck.Files[1].FileData, true))
                {
                    xfheader = fntR.ReadStruct <XFHeader>();

                    fntR.BaseStream.Position = xfheader.table0Offset << 2;
                    t0Comp = (Level5.Method)(fntR.ReadInt32() & 0x7);
                    fntR.BaseStream.Position -= 4;
                    tempCharSizeInfo          = new BinaryReaderX(new MemoryStream(Level5.Decompress(fntR.BaseStream))).ReadMultiple <CharSizeInfo>(xfheader.table0EntryCount);

                    fntR.BaseStream.Position = xfheader.table1Offset << 2;
                    t1Comp = (Level5.Method)(fntR.ReadInt32() & 0x7);
                    fntR.BaseStream.Position -= 4;
                    dicGlyphLarge             = new BinaryReaderX(new MemoryStream(Level5.Decompress(fntR.BaseStream))).ReadMultiple <CharacterMap>(xfheader.table1EntryCount).ToDictionary(x => x.code_point);

                    fntR.BaseStream.Position = xfheader.table2Offset << 2;
                    t2Comp = (Level5.Method)(fntR.ReadInt32() & 0x7);
                    fntR.BaseStream.Position -= 4;
                    dicGlyphSmall             = new BinaryReaderX(new MemoryStream(Level5.Decompress(fntR.BaseStream))).ReadMultiple <CharacterMap>(xfheader.table2EntryCount).ToDictionary(x => x.code_point);
                }

                #region Expand charsizeinfo
                lstCharSizeInfoLarge = new Dictionary <char, CharSizeInfo>();
                lstCharSizeInfoSmall = new Dictionary <char, CharSizeInfo>();
                foreach (var dic in dicGlyphLarge)
                {
                    lstCharSizeInfoLarge.Add(dic.Value.code_point, new CharSizeInfo
                    {
                        offset_x    = tempCharSizeInfo[dic.Value.CharSizeInfoIndex].offset_x,
                        offset_y    = tempCharSizeInfo[dic.Value.CharSizeInfoIndex].offset_y,
                        char_width  = tempCharSizeInfo[dic.Value.CharSizeInfoIndex].char_width,
                        char_height = tempCharSizeInfo[dic.Value.CharSizeInfoIndex].char_height
                    });
                }
                foreach (var dic in dicGlyphSmall)
                {
                    lstCharSizeInfoSmall.Add(dic.Value.code_point, new CharSizeInfo
                    {
                        offset_x    = tempCharSizeInfo[dic.Value.CharSizeInfoIndex].offset_x,
                        offset_y    = tempCharSizeInfo[dic.Value.CharSizeInfoIndex].offset_y,
                        char_width  = tempCharSizeInfo[dic.Value.CharSizeInfoIndex].char_width,
                        char_height = tempCharSizeInfo[dic.Value.CharSizeInfoIndex].char_height
                    });
                }
                #endregion

                var bmpInfo = new BitmapInfo(bmp);

                image_0 = bmpInfo.CreateChannelBitmap(BitmapInfo.Channel.Red);
                image_1 = bmpInfo.CreateChannelBitmap(BitmapInfo.Channel.Green);
                image_2 = bmpInfo.CreateChannelBitmap(BitmapInfo.Channel.Blue);
            }
        }
Beispiel #2
0
 public void Dispose()
 {
     xpck.Close();
     xi = null;
 }