Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

fastest way to compare 2 bitmaps

Posted on 2007-11-21
4
Medium Priority
?
1,632 Views
Last Modified: 2008-02-01
Hello

What's the fastest way to compare 2 bitmaps?
Comparing with GetPixel is veeeeery slow...

I just want to know if bitmap a is the same as b or not...
0
Comment
Question by:Ruttensoft
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20331955
You can use the LockBits and UnlockBits methods to get the image data from a bitmap:
Get data:
 
Dim bounds As New Rectangle(0, 0, bitmap.Width, bitmap.Height)
bitmapData = bitmap.LockBits(bounds, ImageLockMode.Read, PixelFormat.Format32bppRgb)
 
Dim size As Integer = bitmapData.Stride * bitmapData.Height
Dim imageBytes As new Byte(size)
Marshal.Copy(bitmapData.Scan0, imageBytes, 0, size)
bitmap.UnlockBits(bitmapData)

Open in new window

0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20331969
The fastest way is to compare internal bitmap structure, by taking the HBITMAP handle of each.
It is extremely complex, have a look to the C++ code:
http://www.codeproject.com/useritems/BitmapCompare.asp
0
 
LVL 18

Accepted Solution

by:
armoghan earned 2000 total points
ID: 20333488
0
 
LVL 18

Expert Comment

by:armoghan
ID: 20333506
Another interesting debate is present here from
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1057994&SiteID=1

If important thing is not the pixels to be equals, just human readable eye difference, then jo0ls
has given good argument
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question