title: How do I correctly load the char array of a grayscale BMP using CImage?
body: <p>I have the following code:</p>
  
  <pre><code>cout&lt;&lt;"Please enter the name of your BMP image file: "&lt;&lt;endl;
  cin&gt;&gt;fname;
  nP = fname.c_str(); 
  CImage input = CImage();
  input.Load(nP);
  
  // allocate space for host source image
  unsigned char *pHI, *pCI;
  width = input.GetWidth();
  height = input.GetHeight();
  pCI = (unsigned char *)input.GetBits();
  pHI = (unsigned char *)malloc(sizeof(unsigned char) * width * height);
  
  // fill array with CImage array content
  srand (time(NULL));
  for (int cnt = 0; cnt &lt; sizeof(unsigned char) * width * height; cnt++){
      pHI[cnt] = pCI[cnt];
  }
  </code></pre>
  
  <p>But the program gives me an error when I try to get the width and height.</p>
  
  <p>"Debug Assertion Failed! ... Expression: m_hBitmap !=0"</p>
  
  <p>If you have any ideas as to what could be causing this / what I should change, I'd appreciate the help!</p>
  
  <p>: )</p>