Bitmap Font Generator Github



AvatarGenerator
Github

Bitmap Font Generator Github Tutorial

Bitmap font generator github plugin
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.IO;
namespace craigomatic.sample
{
public class AvatarGenerator
{
private List<string> _BackgroundColours;
public AvatarGenerator()
{
_BackgroundColours = new List<string> { 'B26126', 'FFF7F2', 'FFE8D8', '74ADB2', 'D8FCFF' };
}
public Stream Generate(string firstName, string lastName)
{
var avatarString = string.Format('{0}{1}', firstName[0], lastName[0]).ToUpper();
var randomIndex = new Random().Next(0, _BackgroundColours.Count - 1);
var bgColour = _BackgroundColours[randomIndex];
var bmp = new Bitmap(192, 192);
var sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
var font = new Font('Arial', 48, FontStyle.Bold, GraphicsUnit.Pixel);
var graphics = Graphics.FromImage(bmp);
graphics.Clear((Color)new ColorConverter().ConvertFromString('#' + bgColour));
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
graphics.DrawString(avatarString, font, new SolidBrush(Color.WhiteSmoke), new RectangleF(0, 0, 192, 192), sf);
graphics.Flush();
var ms = new MemoryStream();
bmp.Save(ms, ImageFormat.Png);
return ms;
}
}
}
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
  1. Bitmap Font Generator - Documentation. Back to main page. How to interpret the values in the font descriptor file. The image to the right illustrates some of the values found in the font descriptor file.The two dotted lines shows the lineHeight, i.e. How far the cursor should be moved vertically when moving to the next line. The base value is how far from the top of the cell height the base.
  2. Please wait: loading. Wait for generate to complete loading. For best results use close up high contrast pictures. If the page crashes (which it may) just refresh or close and re-open the tab/window.

Bitmap Font Generator Github Generator

Codehead’s Bitmap Font Generator Posted: 17 Mar 2015 at 00:08 by Codehead One of the big problems OpenGL runs into after you’ve got your first few polygons flying around the screen is the lack of a standard method for generating text within the API.