// outRaw_half.cpp - creating a raw image computationally
#include <iostream>
#include <fstream>

int main() {
  using namespace std;

  // stores filename of RAW file to be written
  char filename[20];  
  // used for assigning byte values to RAW file
  // unsigned is used for 0-255 values.
  unsigned char val = 0;  
  
  // reads in filename for RAW file (be sure to include the .raw)
  cout << "Enter a filename (e.g. pic.raw):";
  cin >> filename;
  
  // create ofstream object and open file
  ofstream fout;
  fout.open(filename);
  
  // writing byte values to the image 
  // (first 200 are black, remaining 200 are gray)
  for(int i=0;i<400;i++) {
    if (i<200) val = 0;
    else val = 125;
    fout << val;
  }

  // remember to close your files when done
  fout.close();

}

