public static async Task WriteGTF(Stream outStream, Bitmap bitmap, int encodingType) { GTF gtf = CreateFromBitmap(bitmap, encodingType); using Stream gtfStream = gtf.GetGtfStream(); await gtfStream.CopyToAsync(outStream); }
public static Font CreateFromCharsDir(string srcDir) { DirectoryInfo dInfo = new DirectoryInfo(srcDir); if (!dInfo.Exists) { throw new FileNotFoundException(); } CharData[] chars = LoadCharBitmapExtraData(dInfo.FullName + "/fontdata.dat"); Dictionary <ushort, int[]> charBitmaps = new Dictionary <ushort, int[]>(); for (int i = 0; i < chars.Length; i++) { using Bitmap bitmap = new Bitmap($"{dInfo.FullName}\\{chars[i].key:X4}.png"); charBitmaps.Add(chars[i].key, GetPixelData( bitmap, out int width, out int height)); if (width > 255 || height > 255) { throw new Exception("Bitmap is too big for a character (should be at most 255x255 px)."); } chars[i].datawidth = (byte)width; chars[i].dataheight = (byte)height; } int[] newBitmap = BuildBitmap(charBitmaps, chars); Font font = new Font( GTF.CreateFromPixelData(newBitmap, 0x83, BigBitmapWidth, BigBitmapHeight, BigBitmapStride), chars, 0); font.BuildTree(); return(font); }
public static GTF CreateFromPixelData(int[] pixelData, int encodingType, int width, int height, int stride) { GTF gtf = new GTF(pixelData, encodingType, width, height, stride); gtf.CopyPixelDataToBitmap(); return(gtf); }
public static GTF CreateFromBitmap(Bitmap bitmap, int encodingType) { int width = bitmap.Width; int height = bitmap.Height; int stride = width; int[] pixelData = new int[stride * height]; GTF gtf = new GTF(pixelData, encodingType, width, height, stride); gtf.LoadBitmap(bitmap); return(gtf); }
public ColorChannelGTF(GTF gtf) { Gtf = gtf; }
private Font(GTF gtf, CharData[] chars, int root) { Gtf = gtf; this.chars = chars; this.root = root; }