Page 1 of 1

compare ...wxImage or wxBitmap

Posted: Mon Dec 18, 2006 3:54 pm
by roarek82
Is it possible to compare bitmaps in wxWidgets?
I mean sth like that:

bmp = new wxEmptyBitmap(0,0)
bmp2 = new wxEmptyBitmap(0,0)
bmp.LoadFile("f:/documenti/calcio.bmp", wxBITMAP_TYPE_BMP);
bmp2.LoadFile("f:/documenti/calcio2.bmp", wxBITMAP_TYPE_BMP);

and now I want sth like that
if (bmp==bmp2) {

is there any way to compare bitmaps wxBitmap eventually images(wxImage)?


Posted: Mon Dec 18, 2006 5:07 pm
by ddv
I would say that you have to compare the data returned by wxImage::GetData().
Either byte per byte if you have only 2 images to compare, or using a MD5 like algorithm if you have several images to compare.

Posted: Tue Dec 19, 2006 7:55 am
by upCASE
In addition to what ddv said, I'd firstly check the obvious parameters. Use GetHeight() and GetWidth() for example. Then either use GetData() and compare it this way, or use the GetRed(), GetGreen() and GetBlue() methods.

Posted: Tue Dec 19, 2006 9:33 am
by jgeorgal
In addition to the above suggestions,

If you want to do a somewhat "fuzzy" matching of the images and be able to discover similar or the same images even if they have different sizes you can calculate and compare their color histograms: