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);

Signature
Thanks
Bob Powell [MVP] - 29 Sep 2003 12:58 GMT
OTTOMH I would suggest that the structure definitions might need more strict
specifications. For example you may wish to specify Int16 instead of int.
For Example, in your definition of GLYPMETRICS you've specified "int"
instead of Int16 for the fields that are marked "short" in the Win32
definition.
--
Bob Powell [MVP]
C#, System.Drawing
September's edition of Well Formed is now available.
http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
> Hello,
>
[quoted text clipped - 60 lines]
> --
> Thanks
Mattias Sj?gren - 29 Sep 2003 15:52 GMT
Alexandre,
>[StructLayout(LayoutKind.Sequential)]
>public struct FIXED
>{
>public int fract;
>public int Value;
>}
As Bob said, those members should be shorts, not ints.
public struct FIXED
{
public short fract;
public short Value;
}
>[StructLayout(LayoutKind.Sequential)]
>public struct GLYPHMETRICS
[quoted text clipped - 6 lines]
>public int gmCellIncY;
>}
gmCellIncX and gmCellIncY should also be short members.
>[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);
The declaration should be
[DllImport("gdi32.dll", CharSet=CharSet.Auto)]
public static extern int GetGlyphOutline (IntPtr hdc, int uChar, int
fuFormat, out PhoebeReport.GLYPHMETRICS lpgm, int cbBuffer, IntPtr
lpBuffer, ref PhoebeReport.MAT2 lpmat2);
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.