How can I compare two pixbufs

How do I find whether two Gdk::pixbufs are equal or not (I mean comparing it pixel by pixel)?
The normal == operator does not work , it instead validates that the two pointers are pointing to the same instance , the description says:

bool Glib::RefPtr<Gdk::Pixbuf>::operator==(const Glib::RefPtr<Gdk::Pixbuf> &src) const noexcept
Tests whether the RefPtr<> point to the same underlying instance.

The code:

        if(original_image == Gdk::Pixbuf::create_from_file(file)){
            return false;
        }else{
            return true;
        }

You’ll have to get the pixel buffer out of the GdkPixbuf instance, and then go over it.

Comparing pixels can be really expensive, so you should definitely not hide it behind a simple == comparison.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.