Solved

fastest way to compare 2 bitmaps

Posted on 2007-11-21
4
1,630 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

627 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