private EngFontResourceObject()
{
// Load Resources
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EngFontResourceObject));
Byte[] widthTable = (Byte[])resources.GetObject("WidthTable");
Bitmap fontBitmap = (Bitmap)resources.GetObject("Font");
System.Resources.ResourceManager miscres = new System.Resources.ResourceManager("AtelierElieScripter.Res.Misc", System.Reflection.Assembly.GetExecutingAssembly());
textBox = (Bitmap)miscres.GetObject("TextBox");
if (fontBitmap.GetPixel(0, 0).ToArgb() == Color.Black.ToArgb())
fontBitmap = Lib.Tools.InvertImage(fontBitmap);
int xCount = fontBitmap.Width / FONTTILEWIDTH;
int yCount = fontBitmap.Height / FONTTILEHEIGHT;
int charCount = xCount * yCount;
fontChars = new Bitmap[charCount];
Imaging.PixelFormat format = fontBitmap.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);
for (int i = 0; i < yCount; i++)
{
for (int j = 0; j < xCount; j++)
{
int charcount = i * xCount + j;
Rectangle rect = new Rectangle(j * FONTTILEWIDTH, i * FONTTILEHEIGHT, FONTTILEWIDTH, FONTTILEHEIGHT);
Bitmap character = new Bitmap(FONTTILEWIDTH, FONTTILEHEIGHT);
Bitmap clone = fontBitmap.Clone(rect, format);
using (Graphics g = Graphics.FromImage(character))
{
g.DrawImage(clone, new Rectangle(0, 1, FONTTILEWIDTH, FONTTILEHEIGHT), 0, 0, FONTTILEWIDTH, FONTTILEHEIGHT, GraphicsUnit.Pixel, shadowattr);
g.DrawImage(clone, new Rectangle(0, 0, FONTTILEWIDTH, FONTTILEHEIGHT), 0, 0, FONTTILEWIDTH, FONTTILEHEIGHT, GraphicsUnit.Pixel, attr);
}
fontChars[charcount] = character;
}
}
fontBitmap.Dispose();
fontWidths = new int[charCount];
for (int i = 0; i < charCount; i++)
{
fontWidths[i] = widthTable[i];
}
}