title: How to reshape an Array in c#
body: <p>I have a 3D array of bytes in c# which I have read from a bitmap:</p>
  
  <pre><code>byte[w, h, 3]
  </code></pre>
  
  <p>What is the easiest and more performance-friendly way of reshaping this array into 2D (linear) form?</p>
  
  <pre><code>byte[w*h, 3]
  </code></pre>
  
  <p>In other words I want to keep number of channels (features) but in a linear shape (rather than a square shape)</p>
  
  <p>Let me try to illustrate input and desired output:</p>
  
  <p>input:</p>
  
  <pre><code>|(r1,g1,b1)    (r2,g2,b2)    (r3,g3,b3)|
  |(r4,g4,b4)    (r5,g5,b5)    (r6,g6,b6)|
  |(r7,g7,b7)    (r8,g8,b8)    (r9,g9,b9)|
  </code></pre>
  
  <p>note that arr[0, 0, 0] = r1, arr[0, 0, 1] = g1, arr[0, 0, 2] = b1, etc..</p>
  
  <p>and output:</p>
  
  <pre><code>|(r1,g1,b1)    (r2,g2,b2)    (r3,g3,b3)    (r4,g4,b4)    (r5,g5,b5)    (r6,g6,b6) ...|
  </code></pre>