Esempio n. 1
0
        public CharBox[] readAllChars()
        {
            CharBox[]      all       = new CharBox[chars];
            BitArrayReader rowBM     = new BitArrayReader(font, 5);
            BitArrayReader collBM    = new BitArrayReader(font, collBMstart);
            int            collBMpos = 0;
            int            dataPos   = dataStart;

            byte?bitRow  = rowBM.getBit(0);
            byte?bitColl = collBM.getBit(collBMpos);

            for (int i = 0; i < chars; i++)
            {
                all[i] = new CharBox(withB, height); // empty char object
                FillCharData(all[i], rowBM, collBM, ref dataPos, ref bitRow, ref bitColl);
                all[i].UnXor();                      // unpack char data
            }
            return(all);
        }
Esempio n. 2
0
        public CharBox readChar(int pos)
        {
            CharBox        box       = new CharBox(withB, height); // empty char object
            BitArrayReader rowBM     = new BitArrayReader(font, 5);
            BitArrayReader collBM    = new BitArrayReader(font, collBMstart);
            int            collBMpos = 0;
            int            dataPos   = dataStart;

            byte?bitRow  = rowBM.getBit(0);
            byte?bitColl = collBM.getBit(collBMpos);

            SkipPreviousCharacters(pos, rowBM, collBM, ref dataPos, ref bitRow, ref bitColl);

            FillCharData(box, rowBM, collBM, ref dataPos, ref bitRow, ref bitColl);

            box.UnXor(); // unpack char data

            return(box);
        }
Esempio n. 3
0
 private void FillCharData(CharBox box, BitArrayReader rowBM, BitArrayReader collBM, ref int dataPos, ref byte?bitRow, ref byte?bitColl)
 {
     foreach (var row in box.box)
     {
         if (bitRow > 0)
         {
             for (int c = 0; c < withB; c++)
             {
                 if (bitColl > 0)
                 { // non-zero byte was saved
                     row.Row[c] = font[dataPos];
                     //Console.WriteLine("Reading @{0} {1}", dataPos, font[dataPos]);
                     dataPos++;
                 }
                 bitColl = collBM.getNextBit();
             }
         }
         bitRow = rowBM.getNextBit();
     }
 }
Esempio n. 4
0
        // Rotate
        public CharBox(CharBox bR)
        {
            m_step   = 1;
            m_height = bR.box[0].Width;
            int width = bR.box.Length;

            box = new CharRow[m_height];
            for (int i = 0; i < m_height; i++)
            {
                int bWidth = (width / 8);
                if ((width & 7) > 0)
                {
                    bWidth++;
                }
                box[i] = new CharRow(bWidth);
                for (int j = 0; j < width; j++)
                {
                    if (bR.box[j].getBit(i))
                    {
                        box[i].setBit(j);
                    }
                }
            }
        }
Esempio n. 5
0
        static void Main()
        {
            CharBox b = new CharBox(StaticData.b24x36); // packed ! as byte array
            int     size;

            size = b.bitSize();                                // 113
            b.UnXor();
            size = b.bitSize();                                // 278
            b    = new CharBox(StaticData.raw36x40, '*');      // Star of David as string array
            size = b.bitSize();                                // 750
            b.Xor();
            size = b.bitSize();                                // 705
            var tb = new CharBox(StaticData.raw36x40txt, '*'); // Star of David as single string

            tb.Xor();
            tb.UnXor();
            PackedBoxReader font = new PackedBoxReader(StaticData.fontMedium2); // packed font
            var             chars = font.readAllChars();
            string          printOut = "";
            int             normalSize = 0, xoredSize = 0; // 42143 / 24153

            for (int i = 0; i < font.CharNo; i++)
            {
                string[] charOut = new string[font.Height];
                normalSize += chars[i].bitSize();
                for (int j = 0; j < font.Height; j++)
                {
                    var c = chars[i].box[j];
                    charOut[j] = c.ToString() + '│';
                }
                chars[i].Xor();
                xoredSize += chars[i].bitSize();
                for (int j = 0; j < font.Height; j++)
                {
                    var c = chars[i].box[j];
                    printOut += charOut[j] + c.ToString() + Environment.NewLine;
                }
                printOut += new string('─', chars[i].box[0].Row.Count() * 8) +
                            "┼" +
                            new string('─', chars[i].box[0].Row.Count()) +
                            "┼" +
                            new string('─', chars[i].box[0].Row.Count() * 8) +
                            "┼" +
                            new string('─', chars[i].box[0].Row.Count()) +
                            "\r\n";
            }

            PackedFontWriter pf        = new PackedFontWriter(chars);
            string           fontPrint = pf.getFormatedData(); /*
                                                                * header	5
                                                                * rowBM	423
                                                                * collBM	479
                                                                * data	2118 => 3025B => 24200b
                                                                */

            fontPrint += "/*\r\n" + printOut + "*/\r\n";

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }