Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

fastest way to compare 2 bitmaps

Posted on 2007-11-21
4
Medium Priority
?
1,631 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 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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 …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 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