|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to find equal images?There are some Images (System.Drawing.Image) with same widths and heights,
I want to find if 2 images are equal. How can I do it? The following code always returns false: If img1.Equals(img2) Then MsgBox("ok!") Else MsgBox("wrong!") End If > The following code always returns false: yes because you are checking if the 2 pictures are identical not only in size but also as image , if there is one bit different set it will return false although you might not see it with the naked eye but what you want checking the size can you easily do with a custom function < not behind my dev pc modus so check for typo`s > private function ImgCheckSameSize(byval ImageA as image , ImageB as image ) as boolean if (ImageA.Width = ImageB.Width) AndAlso ( ImageA.Height=ImageB.Height) then return true end if end function regards Michel Posseth [MCP] Show quoteHide quote "Saber" <saber[.AT.]oxin.ir> schreef in bericht news:%23LW69YHnGHA.4172@TK2MSFTNGP03.phx.gbl... > There are some Images (System.Drawing.Image) with same widths and heights, > I want to find if 2 images are equal. > How can I do it? > > The following code always returns false: > > If img1.Equals(img2) Then > MsgBox("ok!") > Else > MsgBox("wrong!") > End If > > Michel,
I don't want checking the size, as I said, the size of images are exactly equal, and the Equals method of Object *always* returns false even when I get the images from "one" image file. I think I've to do Andrew's solution and compare the images pixel by pixel. Thanks Show quoteHide quote "Michel Posseth [MCP]" <M***@posseth.com> wrote in message news:udPcJNOnGHA.620@TK2MSFTNGP05.phx.gbl... >> The following code always returns false: > > yes because you are checking if the 2 pictures are identical not only in > size but also as image , if there is one bit different set it will return > false although you might not see it with the naked eye > > > but what you want checking the size can you easily do with a custom > function > > < not behind my dev pc modus so check for typo`s > > > private function ImgCheckSameSize(byval ImageA as image , ImageB as > image ) as boolean > > if (ImageA.Width = ImageB.Width) AndAlso ( ImageA.Height=ImageB.Height) > then > return true > end if > end function > > regards > > Michel Posseth [MCP] > > > > "Saber" <saber[.AT.]oxin.ir> schreef in bericht > news:%23LW69YHnGHA.4172@TK2MSFTNGP03.phx.gbl... >> There are some Images (System.Drawing.Image) with same widths and >> heights, >> I want to find if 2 images are equal. >> How can I do it? >> >> The following code always returns false: >> >> If img1.Equals(img2) Then >> MsgBox("ok!") >> Else >> MsgBox("wrong!") >> End If >> >> > > Saber wrote:
> There are some Images (System.Drawing.Image) with same widths and See the help for for System.Drawing.Image.Equals - what it's testing for is > heights, I want to find if 2 images are equal. > How can I do it? > > The following code always returns false: > > If img1.Equals(img2) Then > MsgBox("ok!") > Else > MsgBox("wrong!") > End If if img1 and img2 point to the same object. If this is some sort of image-matching game (like http://en.wikipedia.org/wiki/Concentration_%28game%29) then it will probably be much better to get the computer to remember which images are the same instead of comparing them pixel-by-pixel. Iterating over two images and comparing each value from System.Drawing.Bitmap.GetPixel could be slow. I suspect there's a quicker way not using the .net framework. Google could be your friend. Andrew
Close all forms but Main
converting string to image..?? Visual Basic .NET Compiler Printer Command ClickOnce amortization... kinda how to create shift-F2 function for Textbox - shortcutkey? Store encrypted password in my.settings? VB.NET 2.0 & Application Settings.. VB Express: Can't Add New Icon File |
|||||||||||||||||||||||