title: Fast copy of Color32[] array to byte[] array
body: <p>What would be a fast method to <strong>copy/convert</strong> an <code>array</code> of <code>Color32[]</code> values to a <code>byte[]</code> buffer?
  <code>Color32</code> is a struct from Unity 3D containing <code>4 bytes, R, G, B and A respectively</code>.
  What I'm trying to accomplish is to send the rendered image from unity through a pipe to another application (<code>Windows Forms</code>). Currently I'm using this code:</p>
  
  <pre><code>private static byte[] Color32ArrayToByteArray(Color32[] colors)
  {
      int length = 4 * colors.Length;
      byte[] bytes = new byte[length];
      IntPtr ptr = Marshal.AllocHGlobal(length);
      Marshal.StructureToPtr(colors, ptr, true);
      Marshal.Copy(ptr, bytes, 0, length);
      Marshal.FreeHGlobal(ptr);
      return bytes;
  }
  </code></pre>
  
  <p>Thankyou and sorry, I'm new to StackOverflow.
  Marinescu Alexandru</p>