title: Reading RAW images in c++ or Do RAW images have headers?
body: <p>I've got some weird images I'm getting from some hardware at work. They're from this weird piece of hardware that has multiple images being stitched together and stored as raw images. Think of one of those computer security displays with four images displayed at once. Basically, it's like that. And then they're being stored as raw images. Annnnd, there's no documentation for this old piece of junk at all.</p>
  
  <p>I tried to write an extractor to split the images into separate raw files. But the raw image software I used to try and read the image I extracted as a test indicates that it's corrupted. I'm currently thinking that even though it's just raw data, there's supposed to be a file header. But no matter how hard I look, I can't seem to find a definition for a raw image file online. I see that there's a ton of different raw image file types, but I can't even find definitions for those. </p>
  
  <p>Any advice for me?</p>
  
  <p>edit: After rereading this, I don't think I'm being very clear. I have made a supposition in reading in my raw file I wish to split, the supposition is that I believe there is no header in the file, and start copying data for the first image I am extracting with the first byte of data. I also make the same supposition in the image file I am writing out, and I write no header as I'm copying out the image. I believe my supposition about no headers is incorrect and am asking for clarification on that. To help elucidate this, I am including the test code I wrote:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  using namespace std;
  
  //size of individual image
  int width  = 400;
  int height = 400;
  
  //size of input image
  int inputWidth  = 1600;
  int inputHeight = 8000;
  
  int offset = 16;
  
  char strInputFile[]  = "captured.raw";
  char strOutputFile[] = "extracted.raw";
  
  int main()
  {
      printf( "Hi\n" );
      FILE* pInput  = NULL;
      FILE* pOutput = NULL;
      char* buf = new char[width];
      memset( buf, 0, width );
  
      pInput  = fopen( strInputFile,"rb" );
      pOutput = fopen( strOutputFile,"wb" );
      if( pInput &amp;&amp; pOutput )
      {
          for( int i = 0; i &lt; height; i++ )
          {
              //read in a row of pixels
              fread( buf, 1, width, pInput );
              //write out the row of pixels
              fwrite( buf, 1, width, pOutput );
              //move the file pointer forward to the next row of pixels
              fseek( pInput, inputWidth - width, SEEK_CUR );
          }
      }
      fclose( pInput );
      fclose( pOutput );
  
      return 0;
  }
  </code></pre>