Exemplo n.º 1
0
        private void testButton_Click(object sender, EventArgs e)
        {
            LBXBlock block = new LBXBlock();

            // FONTS.LBX and IFONTS.LBX both contain palettes and fonts
            lbxReader.close();
            lbxReader.open(gameFolderPathTextBox.Text + "\\" + "FONTS.LBX");

            // load a palette to use
            lbxReader.read(block, 1);
            Palette pal = new Palette();

            // force the last palette entry to white
            block.data[0xFF * 4 + 0] = 0xFF;
            block.data[0xFF * 4 + 1] = 0x33;
            block.data[0xFF * 4 + 2] = 0x33;
            block.data[0xFF * 4 + 3] = 0x33;
            pal.load(block);

            lbxReader.close();
            lbxReader.open(gameFolderPathTextBox.Text + "\\" + "IFONTS.LBX");

            lbxReader.read(block, 0);
            Font font = new Font();

            // FONT THING
            font.load(block, 5);

            font.palette = pal;

            Bitmap   b  = new Bitmap(640, 480);
            Graphics gg = Graphics.FromImage(b);

            gg.Clear(Color.White);

            /*
             * for (int g = 32; g < 128; ++g)
             * {
             *  int x = (g % 16) * (font.maxGlyphWidth + 1) + 1;
             *  int y = (g / 16) * (font.maxGlyphHeight + 1) + 1;
             *  font.renderGlyph((byte)g, b, x, y);
             * }
             */

            font.renderString("Hello, Xus. :)", b, 10, 10);
            font.renderString(@"This seems to be working more or less? 2 + 2 = 4 (usually) \o/ :P", b, 10, 200);
            pictureBox1.Image = b;
            pictureBox1.Refresh();

            string colorList = "";

            for (int i = 0; i < 128; ++i)
            {
                if (font.glyphColors[i] > 0)
                {
                    colorList = colorList + i.ToString() + " ";
                }
            }
            fontColorsListTextBox.Text = colorList;

            lbxReader.close();
        }