1文字分のビットマップ
Exemplo n.º 1
0
        static unsafe void BitBltAlpha(FontBitmap chara, IntPtr dest32bppBitmap, Size destBitmapSize, Point dest)
        {
            int sz = chara.Bitmap.Length;

            if (sz == 0)
            {
                return;
            }

            int dx = dest.X + chara.OffsetBox.Width;
            int dy = dest.Y + chara.OffsetBox.Height;
            int dp = destBitmapSize.Width; // dst pitch (px)

            int sx = Math.Max(0, -dx);
            int sy = Math.Max(0, -dy);
            int ex = Math.Min(chara.BlackBox.Width, destBitmapSize.Width - dx);
            int ey = Math.Min(chara.BlackBox.Height, destBitmapSize.Height - dy);
            int sw = chara.BlackBox.Width;

            fixed(byte *srcBitmap = &chara.Bitmap[0])
            {
                if (chara.Bpp == 8)
                {
                    BitBltAlpha8((uint *)dest32bppBitmap, dx, dy, dp, srcBitmap, sx, sy, ex, ey, sw);
                }
                else if (chara.Bpp == 1)
                {
                    BitBltAlpha1((uint *)dest32bppBitmap, dx, dy, dp, srcBitmap, sx, sy, ex, ey, sw);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }
Exemplo n.º 2
0
        static unsafe void BitBltAlpha(FontBitmap chara, IntPtr dest32bppBitmap, Size destBitmapSize, Point dest)
        {
            int sz = chara.Bitmap.Length;
            if (sz == 0) return;

            int dx = dest.X + chara.OffsetBox.Width;
            int dy = dest.Y + chara.OffsetBox.Height;
            int dp = destBitmapSize.Width; // dst pitch (px)

            int sx = Math.Max(0, -dx);
            int sy = Math.Max(0, -dy);
            int ex = Math.Min(chara.BlackBox.Width, destBitmapSize.Width - dx);
            int ey = Math.Min(chara.BlackBox.Height, destBitmapSize.Height - dy);
            int sw = chara.BlackBox.Width;

            fixed (byte* srcBitmap = &chara.Bitmap[0])
            {
                if (chara.Bpp == 8) BitBltAlpha8((uint*)dest32bppBitmap, dx, dy, dp, srcBitmap, sx, sy, ex, ey, sw);
                else if (chara.Bpp == 1) BitBltAlpha1((uint*)dest32bppBitmap, dx, dy, dp, srcBitmap, sx, sy, ex, ey, sw);
                else throw new NotImplementedException();
            }
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        /// <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;
        }