Solved

fastest way to compare 2 bitmaps

Posted on 2007-11-21
4
1,626 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 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 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