Search code examples
c++qtqimageqdebug

How to print all the raw data of QImage for comparisons in the memory?


I have two QImage objects which should be equal but the result of QImage::operator== is false. So I want to print all the raw data of the two objects for the comparison. How to do that? Can it be done with qDebug()?


Solution

  • If You want to print values of each pixel, then use bits() method of QImage to get pointer to all pixel values in unsigned char and just print them in for loop. For example if You have 32-bit pictures then in table returned by bits() You will have 4 values for each pixel (Red, Green, Blue, Alpha) and to know how many of those You have just use width()*height()*4 (if it's 32-bit depth). Or You can compare every single pixel instead of printing and return only those which differ.