Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public ColorChannelGTF(GTF gtf)
 {
     Gtf = gtf;
 }
Exemplo n.º 6
0
 private Font(GTF gtf, CharData[] chars, int root)
 {
     Gtf        = gtf;
     this.chars = chars;
     this.root  = root;
 }