Cairo.Context.FromGlyphToUnManagedMemory C# (CSharp) Метод

FromGlyphToUnManagedMemory() статический приватный Метод

static private FromGlyphToUnManagedMemory ( Glyph glyphs ) : IntPtr
glyphs Glyph
Результат System.IntPtr
        internal static IntPtr FromGlyphToUnManagedMemory(Glyph [] glyphs)
        {
            IntPtr dest = Marshal.AllocHGlobal (native_glyph_size * glyphs.Length);
            long pos = dest.ToInt64();

            if (c_compiler_long_size == 8){
                foreach (Glyph g in glyphs){
                    Marshal.StructureToPtr (g, (IntPtr)pos, false);
                    pos += native_glyph_size;
                }
            } else {
                foreach (Glyph g in glyphs){
                    NativeGlyph_4byte_longs n = new NativeGlyph_4byte_longs (g);

                    Marshal.StructureToPtr (n, (IntPtr)pos, false);
                    pos += native_glyph_size;
                }
            }

            return dest;
        }

Usage Example

        public TextExtents GlyphExtents(Glyph[] glyphs)
        {
            IntPtr      ptr = Context.FromGlyphToUnManagedMemory(glyphs);
            TextExtents extents;

            NativeMethods.cairo_scaled_font_glyph_extents(handle, ptr, glyphs.Length, out extents);

            Marshal.FreeHGlobal(ptr);
            return(extents);
        }