Hello everyone, I have an image assets / stall.png where asset is a directory located under the root of my program. I would like to copy my image in memory starting from img_flip.
This is the code that I wrote:
Qt Code:
  1. QImage img;
  2. img.load(filename);
  3. if (img.isNull())
  4. {
  5. printf( "unable to open image: %s\n", filename );
  6. return 0;
  7. }
  8.  
  9. QImage gldata = QGLWidget::convertToGLFormat(img);
  10. uchar *pixels = (uint8_t *)gldata.bits();
  11.  
  12. //vertically flip the image
  13. int img_size = gldata.width() * gldata.height() * gldata.depth();
  14. uint8_t *img_flip = new uint8_t[ img_size ];
  15.  
  16. const int row_width = gldata.width() * gldata.depth();
  17.  
  18. for( int i = 0; i < gldata.height(); i++ )
  19. memcpy( img_flip + ( i * row_width ), pixels + ( (gldata.height() - i - 1) * row_width ),
  20. row_width );
To copy to clipboard, switch view to plain text mode 
I must have made a mistake because the execution stops after copying with i = 7.
Can you help me fix my error ?