예제 #1
0
        /// <summary>
        /// 获取轮廓多边形列表
        /// </summary>
        /// <param name="hdc">场景</param>
        /// <param name="uChar">字符</param>
        /// <returns></returns>
        private static String GetOutline(IntPtr hdc, uint uChar)
        {
            outline.Clear();

            // 转置矩阵
            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)
                    {
                        //构建轮廓

                        // width, height
                        outline.AppendFormat("{0},{1},$$POLY_SIZE$$,", lpGlyph.gmBlackBoxX, lpGlyph.gmBlackBoxY);
                        //从缓存区构造字型轮廓
                        GetPolygons(buffer, bufferSize);

                        return(outline.ToString());
                    }
                    else
                    {
                        throw new Exception("获取字型数据失败!");
                    }
                }
                finally
                {
                    //释放托管内存
                    Marshal.FreeHGlobal(buffer);
                }
            }
            else
            {
                throw new Exception("未能获取缓存区!");
            }
        }
예제 #2
0
        /// <summary>
        /// ��ȡ����������б�
        /// </summary>
        /// <param name="hdc">����</param>
        /// <param name="uChar">�ַ�</param>
        /// <returns></returns>
        private static String GetOutline(IntPtr hdc, uint uChar)
        {
            outline.Clear();

            // ת�þ���
            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)
                    {
                        //��������

                        // width, height
                        outline.AppendFormat("{0},{1},$$POLY_SIZE$$,", lpGlyph.gmBlackBoxX, lpGlyph.gmBlackBoxY);
                        //�ӻ�����������������
                        GetPolygons(buffer, bufferSize);

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