title: OpenCV how to encode raw image information for imencode?
body: <p>I am in C++.</p>
  
  <p>Assume some mysterious function <code>getData()</code> returns all but only the pixel information of an image.</p>
  
  <p>i.e a <code>char*</code> that points to only the pixel information with no metadata (no width, length, height, nor channels of any form)</p>
  
  <p>Thus we have:</p>
  
  <p><code>unsigned char *raw_data = getData();</code></p>
  
  <p>Then we have another function that returns a structure containing the metadata.</p>
  
  <p>eg: </p>
  
  <pre><code>struct Metadata {
      int width;
      int height;
      int channels;
      //other useful fields
  }
  </code></pre>
  
  <p>I now need to prepend the object metadata in the correct way to create a valid image buffer.</p>
  
  <p>So instead of <code>[pixel1, pixel2, pixel3 ...]</code></p>
  
  <p>I would have, for example <code>[width, height, channels, pixel1, pixel2, pixel3...]</code></p>
  
  <p>What is the correct order to prepend the metadata and are width, height and channels enough? </p>