title: C++: Convert text file of integers into a bitmap image file in BMP format
body: <p>I have a text file being saved by a matrix library containing a 2D matrix as such:</p>
  
  <pre><code>1 0 0 
  6 0 4
  0 1 1
  </code></pre>
  
  <p>Where each number is represented with a colored pixel. I am looking for some insight as to how I'd go about solving this problem. If any more information is required, do not hesitate to ask. </p>
  
  <p>EDIT: Another approach I've tried is: <code>fwrite(&amp;intmatrix, size,1, bmp_ptr);</code> where I pass in the matrix pointer, which does not seem to output a readable BMP file. The value of <code>size</code> is the <code>rows*cols</code> of course, and the type of matrix is <code>arma::Mat&lt;int&gt;</code> which is a matrix from the Armadillo Linear Algebra Library.</p>
  
  <p>EDIT II: Reading <a href="https://stackoverflow.com/questions/10124517/c-bmp-to-byte-array-in-a-file">this</a> indicated that my size should probably be rows*cols*4 given the size of the rows if I am not mistaken, any guidance on this point as well would be great.</p>