title: QImage::pixel: coordinate (75,3039) out of range
body: <p>For some reason I cannot run my code due to <code>QImage::pixel: coordinate (75,3039) out of range</code>. However I don't know what should I do in order to fix this bug, I tried to search all over the net unsuccessfully.</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      int height;
      int width;
      unsigned char *p, *p_begin;
      QImage img("C:\\Users\\Owner\\Pictures\\2013-09-26\\IMG_0836.JPG");
      height = img.height();
      width = img.width();
      p = (unsigned char *)malloc(height * width * sizeof(unsigned char));
      p_begin = p;
      for (int row = 1; row &lt; 2000 + 1; ++row)
          for (int col = 1; col &lt; 2000 + 1; ++col)
          {
              QColor clrCurrent( img.pixel( row, col ));
              *p = (unsigned char)((clrCurrent.green() * 0.587) +  (clrCurrent.blue() * 0.114) + (clrCurrent.red() * 0.299));
              p++;
          }
  }
  </code></pre>