Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Comparing Bitmap Images

Hi,
Can anyone tell me how to compare two bitmap images? I'm using Windows programming(win32 APIs) with C/C++. I would be thankful if anyone tells me atleast the algorithm so that i can start with.
Thanks,
Faaz.
[238 byte] By [faaz] at [2007-11-11 8:34:10]
# 1 Re: Comparing Bitmap Images
Do you want them exact or "close" or what? If you simply want exact, compare the files byte for byte (well, do it efficiently of course). If you want "close" youll have to define what close means...
jonnin at 2007-11-11 21:01:09 >
# 2 Re: Comparing Bitmap Images
read the bits of each file into an unsigned integral datatype and compare these values, in a loop.
Danny at 2007-11-11 21:02:20 >
# 3 Re: Comparing Bitmap Images
Hi :

Like, jonnin, has sad if you want to compare to image there are 2 ways :
1. compare pixel per pixel.
2. take the most important characteristics of the two images and then compare them.
(Approximation)
Comete32 at 2007-11-11 21:03:13 >
# 4 Re: Comparing Bitmap Images
hi..thax everybody for ur responses...but i need to compare the images exactly..not approximately..also every bitmap file will be having a header i suppose...i think v need to get that info 1st...i dono the exact steps..this is my rough estimation...can anyone help me out with this? also, it would b wonderful if u could provide me with some of the APIs useful for this purpose..

Thanks,
Faaz...
faaz at 2007-11-11 21:04:18 >
# 5 Re: Comparing Bitmap Images
Exactly is the easy one. load the files entirely into 2 memory buffers & do a memcmp on them or use the stl vector comparison to do it. (I ususally do not use vectors unless I need one of the extended functions beyond simple buffer manipulation).
Or, if your really lazy, do a file compare using your OS tools and parse the result.
jonnin at 2007-11-11 21:05:13 >