Beispiel #1
0
        /// <summary>
        /// 获取轮廓多边形列表
        /// </summary>
        /// <param name="hdc">场景</param>
        /// <param name="uChar">字符</param>
        /// <returns></returns>
        private static DOutline GetOutline(IntPtr hdc, uint uChar)
        {
            // 转置矩阵
            MAT2 mat2 = new MAT2();

            mat2.eM11.value = 1;
            mat2.eM22.value = 1;

            GLYPHMETRICS lpGlyph = new GLYPHMETRICS();

            //获取缓存区大小
            int bufferSize = GdiNativeMethods.GetGlyphOutline(hdc, uChar, GGO_NATIVE, out lpGlyph, 0, IntPtr.Zero, ref mat2);

            if (bufferSize > 0)
            {
                //获取成功后,分配托管内存
                IntPtr buffer = Marshal.AllocHGlobal(bufferSize);
                try
                {
                    int ret = GdiNativeMethods.GetGlyphOutline(hdc, uChar, GGO_NATIVE, out lpGlyph, (uint)bufferSize, buffer, ref mat2);
                    if (ret > 0)
                    {
                        //构建轮廓
                        DOutline outline = new DOutline(lpGlyph.gmBlackBoxX, lpGlyph.gmBlackBoxY);
                        //从缓存区构造字型轮廓
                        FillPolygons(outline, buffer, bufferSize);

                        return(outline);
                    }
                    else
                    {
                        throw new Exception("获取字型数据失败!");
                    }
                }
                finally
                {
                    //释放托管内存
                    Marshal.FreeHGlobal(buffer);
                }
            }
            else
            {
                throw new Exception("未能获取缓存区!");
            }
        }
Beispiel #2
0
 public static extern int GetGlyphOutline(IntPtr hdc, uint uChar, uint fuFormat, out GLYPHMETRICS lpgm, uint cbBuffer, IntPtr lpBuffer, ref MAT2 lpmat2);
Beispiel #3
0
        /// <summary>
        /// ��ȡ����������б�
        /// </summary>
        /// <param name="hdc">����</param>
        /// <param name="uChar">�ַ�</param>
        /// <returns></returns>
        private static DOutline GetOutline(IntPtr hdc, uint uChar)
        {
            // ת�þ���
            MAT2 mat2 = new MAT2();
            mat2.eM11.value = 1;
            mat2.eM22.value = 1;

            GLYPHMETRICS lpGlyph = new GLYPHMETRICS();

            //��ȡ��������С
            int bufferSize = GdiNativeMethods.GetGlyphOutline(hdc, uChar, GGO_NATIVE, out lpGlyph, 0, IntPtr.Zero, ref mat2);

            if (bufferSize > 0)
            {
                //��ȡ�ɹ��󣬷����й��ڴ�
                IntPtr buffer = Marshal.AllocHGlobal(bufferSize);
                try
                {
                    int ret = GdiNativeMethods.GetGlyphOutline(hdc, uChar, GGO_NATIVE, out lpGlyph, (uint)bufferSize, buffer, ref mat2);
                    if (ret > 0)
                    {
                        //��������
                        DOutline outline = new DOutline(lpGlyph.gmBlackBoxX, lpGlyph.gmBlackBoxY);
                        //�ӻ�����������������
                        FillPolygons(outline, buffer, bufferSize);

                        return outline;
                    }
                    else
                    {
                        throw new Exception("��ȡ��������ʧ�ܣ�");
                    }
                }
                finally
                {
                    //�ͷ��й��ڴ�
                    Marshal.FreeHGlobal(buffer);
                }
            }
            else
            {
                throw new Exception("δ�ܻ�ȡ��������");
            }
        }
Beispiel #4
0
 public static extern int GetGlyphOutline(IntPtr hdc, uint uChar, uint fuFormat, out GLYPHMETRICS lpgm, uint cbBuffer, IntPtr lpBuffer, ref MAT2 lpmat2);