title: C# - Reshape Array & change type in place
body: <p>I read a huge image (e.g. 1.800MP @ 16 bit per pixel) from disk. <code>Magick.Net</code> provides me with a 1D-Byte array, so every pixel is 2 elements in the array. I need to have a 2d array of <code>ushort</code> for processing.</p>
  
  <p>Needless to say, <code>BlockCopy</code> and alike are forbidden - doubling the memory usage is not an option.</p>
  
  <p>The data already has the right order in memory, I just need to "cast" the array from <code>byte[]</code> to <code>ushort[,]</code> somehow.</p>
  
  <p>So basically, I am looking for a function that does this:</p>
  
  <pre><code>ushort[,] convertByteToUshort(byte[] arr, int width, int height)
  </code></pre>
  
  <p>I know the width &amp; height of the image (and thus, 2d array), and I guess I will need to use <code>unsafe</code> code and <code>fixed</code> for the pointers. But I have no idea how to transform the reference to a true <code>ushort[,]</code>.</p>
  
  <p>Any ideas?</p>