2

How can we compare two QImages ?

I have 2 QImages as below with some actual data in it:

QImage image_1;  
QImage image_2;

If I do a if(image_1 == image_2) & this returns true then does it mean the that the 2 QImages are pixel to pixel same?

Or does it mean that they are equal in sizes?
Or does it mean something completely different?

Note:
My requirement is to confirm that the QImages are pixel to pixel same.
Please suggest if there is a way to do that kindo of comparasion.

GrecKo
  • 6,615
  • 19
  • 23
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
  • 1
    It is usually good idea to read the docs before asking... And if not clear or if docs not found, ask away, buy explain that in the question. – hyde Dec 18 '17 at 22:04

1 Answers1

4

If I do a if(image_1 == image_2) & this returns true then does it mean the that the 2 QImages are pixel to pixel same?

Yes, same pixels: http://doc.qt.io/qt-5/qimage.html#operator-eq-eq

We have equal operator described as:

bool QImage::operator==(const QImage &image) const Returns true if this image and the given image have the same contents; otherwise returns false.

The comparison can be slow, unless there is some obvious difference (e.g. different size or format), in which case the function will return quickly.

Alexander V
  • 8,351
  • 4
  • 38
  • 47