コード例 #1
0
 /// <summary>
 /// Creates byte array from vtkImageData
 /// </summary>
 /// <param name="idata"></param>
 /// <returns></returns>
 public static byte[] getArrayFromImageData(vtkImageData idata)
 {
     int width = (int)(idata.GetBounds()[1] - idata.GetBounds()[0]) + 1;
     int height = (int)(idata.GetBounds()[3] - idata.GetBounds()[2]) + 1;
     byte[] arr = new byte[width * height * idata.GetNumberOfScalarComponents()];
     System.Runtime.InteropServices.Marshal.Copy(
         ((IntPtr)idata.GetScalarPointer()),
         arr,
         0,
         width * height * idata.GetNumberOfScalarComponents());
     return arr;
 }
コード例 #2
0
    /// <summary>
    /// Creates byte array from vtkImageData
    /// </summary>
    /// <param name="idata"></param>
    /// <returns></returns>
    static public byte[] getArrayFromImageData(vtkImageData idata)
    {
        int width  = (int)(idata.GetBounds()[1] - idata.GetBounds()[0]) + 1;
        int height = (int)(idata.GetBounds()[3] - idata.GetBounds()[2]) + 1;

        byte[] arr = new byte[width * height * idata.GetNumberOfScalarComponents()];
        System.Runtime.InteropServices.Marshal.Copy(
            ((IntPtr)idata.GetScalarPointer()),
            arr,
            0,
            width * height * idata.GetNumberOfScalarComponents());
        return(arr);
    }