shah123
May 31st, 2007, 06:29 AM
How to compare 2 pictures in 2 different picture boxes in C#?
|
Click to See Complete Forum and Search --> : How to compare pictures in 2 different picture boxes shah123 May 31st, 2007, 06:29 AM How to compare 2 pictures in 2 different picture boxes in C#? Talikag May 31st, 2007, 07:06 AM What do you mean compare? You want to check if it's the same picture? shah123 May 31st, 2007, 07:16 AM Yes something like if (Object.Equals(box1.Image,box5.Image,box9.Image)) // that doesnt work But i have to compare 3 pictures at one time? laitinen May 31st, 2007, 07:39 AM But i have to compare 3 pictures at one time? Are you able to compare two pictures? Then first compare pic1 and pic2. If they are equal you compare one of them with pic3. Laitinen Talikag May 31st, 2007, 08:00 AM There is no ComparesTo method or something similar. What you can do to compare is to create your own == operator that gets 2 images. There you will save the both images as files, and read from each. If the strings that you read equal, return true, otherwise, return false. Of course you should delete it before returning a value. [CODE] ... pictureBox1.Image.Save(@"C:/Image1", System.Drawing.Imaging.ImageFormat.Png); pictureBox2.Image.Save(@"C:/Image1", System.Drawing.Imaging.ImageFormat.Png); System.IO.StreamReader StreamReader1 = new System.IO.StreamReader(@".../Image1.jpg"); System.IO.StreamReader StreamReader2 = new System.IO.StreamReader(@".../Image2.jpg"); if(StreamReader1.ReadToEnd() == StreamReader2.ReadToEnd()) { //Delete files return true; } //Delete files return false; shah123 May 31st, 2007, 09:49 AM yes saving to file is a nice idea. Got It working in slightly different way but thanks Guys Talikag May 31st, 2007, 10:01 AM yes saving to file is a nice idea. Got It working in slightly different way but thanks Guys Can you please post here the way you did it? It's really cause curiosity... shah123 May 31st, 2007, 11:38 AM Sorry usually i post answer as well but forgot. I found the solution which was lengthy but here it is public bool CompareImages(Image image1,Image image2,Image image3) { if(!Object.Equals(image1,image2)) { return false; } if(!Object.Equals(image2,image3)) { return false; } return true; } public void checkAll() { if (CompareImages(box1.Image, box2.Image, box3.Image)) { DisplayWinner(); } else if (CompareImages(box4.Image, box5.Image, box6.Image)) { DisplayWinner(); } } codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |