/// <summary> /// Returns the values of the pixels as an array. /// </summary> ///<param name="x">The X coordinate of the area.</param> ///<param name="y">The Y coordinate of the area.</param> ///<param name="width">The width of the area.</param> ///<param name="height">The height of the area.</param> ///<param name="mapping">The mapping of the pixels (e.g. RGB/RGBA/ARGB).</param> public byte[] ToByteArray(int x, int y, int width, int height, string mapping) { Throw.IfNullOrEmpty("mapping", mapping); CheckArea(x, y, width, height); IntPtr nativeResult = _NativeInstance.ToByteArray(x, y, width, height, mapping); byte[] result = ByteConverter.ToArray(nativeResult, width * height * mapping.Length); MagickMemory.Relinquish(nativeResult); return(result); }
public static StringInfo CreateInstance(IntPtr instance) { if (instance == IntPtr.Zero) { return(null); } NativeStringInfo native = new NativeStringInfo(instance); return(new StringInfo { Datum = ByteConverter.ToArray(native.Datum, native.Length), }); }
internal static string NativeToManaged(IntPtr nativeData) { byte[] strbuf = ByteConverter.ToArray(nativeData); if (strbuf == null) { return(null); } if (strbuf.Length == 0) { return(string.Empty); } return(Encoding.UTF8.GetString(strbuf, 0, strbuf.Length)); }
public static StringInfo?CreateInstance(IntPtr instance) { if (instance == IntPtr.Zero) { return(null); } var native = new NativeStringInfo(instance); var datum = ByteConverter.ToArray(native.Datum, native.Length); if (datum == null) { return(null); } return(new StringInfo(datum)); }
public virtual byte[] ToByteArray(int x, int y, int width, int height, string mapping) { var nativeResult = IntPtr.Zero; byte[] result = null; try { nativeResult = _nativeInstance.ToByteArray(x, y, width, height, mapping); result = ByteConverter.ToArray(nativeResult, width * height * mapping.Length); } finally { MagickMemory.Relinquish(nativeResult); } return(result); }
/// <summary> /// Returns the values of the pixels as an array. /// </summary> /// <param name="x">The X coordinate of the area.</param> /// <param name="y">The Y coordinate of the area.</param> /// <param name="width">The width of the area.</param> /// <param name="height">The height of the area.</param> /// <param name="mapping">The mapping of the pixels (e.g. RGB/RGBA/ARGB).</param> /// <returns>A <see cref="byte"/> array.</returns> public byte[] ToByteArray(int x, int y, int width, int height, string mapping) { Throw.IfNullOrEmpty(nameof(mapping), mapping); CheckArea(x, y, width, height); IntPtr nativeResult = IntPtr.Zero; byte[] result = null; try { nativeResult = _nativeInstance.ToByteArray(x, y, width, height, mapping); result = ByteConverter.ToArray(nativeResult, width * height * mapping.Length); } finally { MagickMemory.Relinquish(nativeResult); } return(result); }