/// <summary> /// 1文字分のグリフを得る /// </summary> /// <param name="c">文字</param> /// <returns>bitmap</returns> public FontBitmap GetCharacterBitmap(char c) { uint flag = Antialiased ? Win32.GGO_GRAY8_BITMAP : Win32.GGO_BITMAP; Win32.GLYPHMETRICS metrics = new Win32.GLYPHMETRICS(); Win32.MAT2 mat2 = Win32.MAT2.Identity; int bufSize = Win32.GetGlyphOutline(hdc, c, flag, ref metrics, 0, null, ref mat2); byte[] buf = new byte[bufSize]; Win32.GetGlyphOutline(hdc, c, flag, ref metrics, (uint)bufSize, buf, ref mat2); FontBitmap bmp = new FontBitmap(); bmp.Char = c; bmp.Bpp = (short)(Antialiased ? 0x8 : 0x1); bmp.Bitmap = buf; bmp.BlackBox = new Size(metrics.gmBlackBoxX, metrics.gmBlackBoxY); bmp.OffsetBox = new Size(metrics.gmptGlyphOriginX, Ascent - metrics.gmptGlyphOriginY); bmp.CellInc = new Size(metrics.gmCellIncX, metrics.gmCellIncY); return(bmp); }
/// <summary> /// 1文字分のグリフを得る /// </summary> /// <param name="c">文字</param> /// <returns>bitmap</returns> public FontBitmap GetCharacterBitmap(char c) { uint flag = Antialiased ? Win32.GGO_GRAY8_BITMAP : Win32.GGO_BITMAP; Win32.GLYPHMETRICS metrics = new Win32.GLYPHMETRICS(); Win32.MAT2 mat2 = Win32.MAT2.Identity; int bufSize = Win32.GetGlyphOutline(hdc, c, flag, ref metrics, 0, null, ref mat2); byte[] buf = new byte[bufSize]; Win32.GetGlyphOutline(hdc, c, flag, ref metrics, (uint)bufSize, buf, ref mat2); FontBitmap bmp = new FontBitmap(); bmp.Char = c; bmp.Bpp = (short)(Antialiased ? 0x8 : 0x1); bmp.Bitmap = buf; bmp.BlackBox = new Size(metrics.gmBlackBoxX, metrics.gmBlackBoxY); bmp.OffsetBox = new Size(metrics.gmptGlyphOriginX, Ascent - metrics.gmptGlyphOriginY); bmp.CellInc = new Size(metrics.gmCellIncX, metrics.gmCellIncY); return bmp; }