compare ...wxImage or wxBitmap Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
roarek82
Earned a small fee
Earned a small fee
Posts: 13
Joined: Sat Aug 26, 2006 2:40 am

compare ...wxImage or wxBitmap

Post 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) {
//code
}

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

roar
ddv
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Dec 18, 2006 4:23 pm

Post 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.
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Hi!
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.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
jgeorgal
Experienced Solver
Experienced Solver
Posts: 58
Joined: Fri Sep 15, 2006 12:47 pm

Post 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:

http://en.wikipedia.org/wiki/Color_histogram

Regards,
Giannis
Post Reply