public IntPtr ToShortArray(int x, int y, int width, int height, string mapping)
{
using (INativeInstance mappingNative = UTF8Marshaler.CreateInstance(mapping))
{
IntPtr exception = IntPtr.Zero;
IntPtr result;
#if PLATFORM_AnyCPU
if (NativeLibrary.Is64Bit)
#endif
#if PLATFORM_x64 || PLATFORM_AnyCPU
result = NativeMethods.X64.PixelCollection_ToShortArray(Instance, (UIntPtr)x, (UIntPtr)y, (UIntPtr)width, (UIntPtr)height, mappingNative.Instance, out exception);
#endif
#if PLATFORM_AnyCPU
else
#endif
#if PLATFORM_x86 || PLATFORM_AnyCPU
result = NativeMethods.X86.PixelCollection_ToShortArray(Instance, (UIntPtr)x, (UIntPtr)y, (UIntPtr)width, (UIntPtr)height, mappingNative.Instance, out exception);
#endif
var magickException = MagickExceptionHelper.Create(exception);
if (magickException == null)
{
return(result);
}
if (magickException is MagickErrorException)
{
if (result != IntPtr.Zero)
{
MagickMemory.Relinquish(result);
}
throw magickException;
}
RaiseWarning(magickException);
return(result);
}
}