1 Color32[]转Inptr

代码示例:

private static IntPtr Color32ArrayToIntptr(Color32[] colors,int length)
{
    if (colors == null || colors.Length == 0)
        return IntPtr.Zero;

    GCHandle handle = default(GCHandle);
    IntPtr ptr = IntPtr.Zero;
    try
    {
        handle = GCHandle.Alloc(colors, GCHandleType.Pinned);
        ptr = handle.AddrOfPinnedObject();
    }
    finally
    {
        if (handle != default(GCHandle))
            handle.Free();
    }
    return ptr;
}