/// <summary> /// Converts the supplied bitmap to a Woopsi font using the specified parameters. /// </summary> /// <param name="className">The C++ classname for the font.</param> /// <param name="bitmapName">The name for the u16 array that stores the font bitmap data.</param> /// <param name="fontType">The type of font to produce. Options are packedfont1 and packedfont16.</param> /// <param name="bitmap">The bitmap to convert.</param> /// <param name="fontWidth">The width of a glyph in the font. If set to -1, the width is calculated /// from the width of the bitmap. In that case, the bitmap must be a multiple of 32 wide.</param> /// <param name="fontHeight">The height of a glyph in the font. If set to -1, the height is calculated /// from the height of the bitmap. In that case, the bitmap must be a multiple of 8 tall.</param> /// <param name="backgroundR">The red component of the background colour. If any component is set to /// -1, the colour is retrieved automatically from the top-left pixel of the bitmap.</param> /// <param name="backgroundG">The green component of the background colour. If any component is set to /// -1, the colour is retrieved automatically from the top-left pixel of the bitmap.</param> /// <param name="backgroundB">The blue component of the background colour. If any component is set to /// -1, the colour is retrieved automatically from the top-left pixel of the bitmap.</param> /// <returns>The converted font.</returns> public static WoopsiFont Convert(string className, string bitmapName, string fontType, Bitmap bitmap, int fontWidth, int fontHeight, int backgroundR, int backgroundG, int backgroundB) { fontWidth = GetFontWidth(fontWidth, bitmap); fontHeight = GetFontHeight(fontHeight, bitmap); WoopsiFont font = new WoopsiFont(fontWidth, fontHeight, className); Color backgroundColour = GetBackgroundColour(backgroundR, backgroundG, backgroundB, bitmap); FontConverterBase converter = null; switch (fontType.ToLower()) { case "packedfont16": converter = new PackedFonts.PackedFontConverter(font, bitmap, backgroundColour, false); break; case "packedfont1": converter = new PackedFonts.PackedFontConverter(font, bitmap, backgroundColour, true); break; } font.BodyContent = converter.OutputCPP; font.HeaderContent = converter.OutputH; return(font); }
/// <summary> /// Constructor. /// </summary> /// <param name="font">The font object that will store the converted data.</param> /// <param name="bitmap">The bitmap to convert.</param> /// <param name="backgroundColour">The background colour of the bitmap.</param> public FontConverterBase(WoopsiFont font, Bitmap bitmap, Color backgroundColour) { mFont = font; mBitmap = bitmap; mBackgroundColour = backgroundColour; }