ImageMagick.ByteConverter.ToArray C# (CSharp) Method

ToArray() public static method

public static ToArray ( IntPtr nativeData ) : byte[]
nativeData System.IntPtr
return byte[]
    public static byte[] ToArray(IntPtr nativeData)
    {
      if (nativeData == IntPtr.Zero)
        return null;

      unsafe
      {
        int length = 0;
        byte* walk = (byte*)nativeData;

        // find the end of the string
        while (*(walk++) != 0)
          length++;

        if (length == 0)
          return new byte[0];

        return ToArray(nativeData, length);
      }
    }

Same methods

ByteConverter::ToArray ( IntPtr nativeData, int length ) : byte[]

Usage Example

Example #1
0
        /// <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);
        }
All Usage Examples Of ImageMagick.ByteConverter::ToArray