How to use GetGlyphOutline with C# ?

A

Alexandre CHATTON

Hello,

I'm trying to integrate the GetGlyphOutline API in a C#
project. My algorithm is working fine with VB6, but I still have problem to
make the appropriate
definitions using C#. Anybody has a solution ?

Declares:

[StructLayout(LayoutKind.Sequential)]
public struct FIXED
{
public int fract;
public int Value;
}

[StructLayout(LayoutKind.Sequential)]
public struct MAT2
{
[MarshalAs(UnmanagedType.Struct)] public PhoebeReport.FIXED eM11;
[MarshalAs(UnmanagedType.Struct)] public PhoebeReport.FIXED eM12;
[MarshalAs(UnmanagedType.Struct)] public PhoebeReport.FIXED eM21;
[MarshalAs(UnmanagedType.Struct)] public PhoebeReport.FIXED eM22;
}

[StructLayout(LayoutKind.Sequential)]
public struct POINTAPI
{
public int x;
public int y;
}

[StructLayout(LayoutKind.Sequential)]
public struct GLYPHMETRICS
{
public int gmBlackBoxX;
public int gmBlackBoxY;
[MarshalAs(UnmanagedType.Struct)] public PhoebeReport.POINTAPI
gmptGlyphOrigin;
public int gmCellIncX;
public int gmCellIncY;
}

'****************************

[DllImport("gdi32.dll")]
public static extern IntPtr GetGlyphOutline (IntPtr hdc, int uChar, int
fuFormat, [In, Out] PhoebeReport.GLYPHMETRICS lpgm, int cbBuffer, [In, Out]
object lpBuffer, PhoebeReport.MAT2 lpmat2);

'****************************


and Call

lpMatrix = new PhoebeReport.MAT2();
lpMatrix.eM11.Value = 1;
lpMatrix.eM22.Value = 1;
lpGlyph = new PhoebeReport.GLYPHMETRICS();
oObj = null;
iRet = GetGlyphOutline(hDC, 0x48, PhoebeReport.FontManager.GGO_METRICS,
lpGlyph, 0, oObj, lpMatrix);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top