title: QImage from datastream
body: <p>I'm using the Qt library, creating QImages.</p>
  
  <p>I'm able to use <a href="http://doc.trolltech.com/4.6/qimage.html#QImage-10" rel="nofollow noreferrer">this constructor</a>:</p>
  
  <pre><code>QImage image("example.jpg");
  </code></pre>
  
  <p>But I'm having trouble with <a href="http://doc.trolltech.com/4.6/qimage.html#fromData-2" rel="nofollow noreferrer">this static function</a>:</p>
  
  <pre><code>char buffer[sizeOfFile];
  ifstream inFile("example.jpg");
  inFile.read(buffer, sizeOfFile);
  QImage image = QImage::fromData(buffer); // error here
  // but there's nothing wrong with the buffer
  ofstream outFile("bufferOut.jpg");
  outFile.write(buffer, sizeOfFile);
  </code></pre>
  
  <p>Where Qt spits out to console:</p>
  
  <pre><code>Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
  JPEG datastream contains no image
  </code></pre>
  
  <p>The above isn't <em>exactly</em> what I have, but it's the only important difference. (I need to be able to read from a buffer because I'm opening images that are inside a zip archive.)</p>