AtelierElieScripter.ResourceObjects.JapFontResourceObject.JapFontResourceObject C# (CSharp) Метод

JapFontResourceObject() приватный Метод

Initializes All Characters and TextBox
private JapFontResourceObject ( ) : System
Результат System
        private JapFontResourceObject()
        {
            // Load Resources
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(JapFontResourceObject));

            Byte[] sjisPointers = (Byte[])resources.GetObject("sjispointertable");
            Byte[] sjisTable = (Byte[])resources.GetObject("SJIStable");
            Bitmap font = (Bitmap)resources.GetObject("JapFont");

            System.Resources.ResourceManager miscres = new System.Resources.ResourceManager("AtelierElieScripter.Res.Misc", System.Reflection.Assembly.GetExecutingAssembly());
            textBox = (Bitmap)miscres.GetObject("TextBox");

            // Initialize Variables
            uint pos = 0;
            List<uint> pointers = new List<uint>();

            // Invert image if bg is black
            if (font.GetPixel(0, 0).ToArgb() == Color.Black.ToArgb())
            {
                font = Lib.Tools.InvertImage(font);
            }

            // Read pointers
            while (pos < sjisPointers.Length)
            {
                uint result = ((uint) sjisPointers[pos+3]) << 24;
                result |= ((uint) sjisPointers[pos+2]) << 16;
                result |= ((uint) sjisPointers[pos+1]) << 8;
                result |= (uint)sjisPointers[pos];
                result -= 0x800C9BC4;

                pointers.Add(result);
                pos += 4;
            }

            // Initialize Variables
            pos = 0;
            uint no = 0;
            uint chara;

            Imaging.PixelFormat format = font.PixelFormat;

            Imaging.ColorMap transcolorMap = new Imaging.ColorMap();

            transcolorMap.OldColor = Color.White;
            transcolorMap.NewColor = Color.FromArgb(0, 0, 0, 0);

            Imaging.ImageAttributes attr = new Imaging.ImageAttributes();
            Imaging.ColorMap colorMap = new Imaging.ColorMap();
            colorMap.OldColor = Color.Black;
            colorMap.NewColor = Color.FromArgb(255, 58, 58, 58);
            Imaging.ColorMap[] remapTable = { colorMap , transcolorMap};
            attr.SetRemapTable(remapTable, Imaging.ColorAdjustType.Bitmap);

            colorMap.NewColor = Color.FromArgb(255, 140, 124, 91);
            Imaging.ColorMap[] shadowremapTable = { colorMap };
            Imaging.ImageAttributes shadowattr = new Imaging.ImageAttributes();
            shadowattr.SetRemapTable(remapTable, Imaging.ColorAdjustType.Bitmap);

            // Copy each character into fontChars with Shadow
            for (int i = 0; i < pointers.Count; i++)
            {
                pos = pointers[i];
                while (true)
                {
                    if (sjisTable[pos] == 0xff)
                    {
                        pos += 4;
                        break;
                    }

                    chara = (uint)(i << 8) + sjisTable[pos] + 0x8140;

                    Rectangle rect = new Rectangle((int)no * 12, (int)i * 12, 12, 12);
                    Bitmap character = new Bitmap(12, 12);

                    Bitmap clone = font.Clone(rect, format);

                    using (Graphics g = Graphics.FromImage(character))
                    {
                        g.DrawImage(clone, new Rectangle(0, 1, 12, 12), 0, 0, 12, 12, GraphicsUnit.Pixel, shadowattr);
                        g.DrawImage(clone, new Rectangle(0, 0, 12, 12), 0, 0, 12, 12, GraphicsUnit.Pixel, attr);
                    }

                    fontChars.Add(chara, character);

                    no += 1;
                    pos += 1;
                    //Debug.WriteLine(chara.ToString("X4") + " ");

                }

                no = 0;
            }
        }