It didn't work, but I will find another way to do it. Thank you for all your help.
dizzyJ
Posts
-
Compare picturebox.image with image from a resource file -
Compare picturebox.image with image from a resource fileWe tried that but,
bild.Image.Save(ms1, System.Drawing.Imaging.ImageFormat.MemoryBmp);
Returns an ArgumentNullException. "Value cannot be null, parameter name: encoder". I guess the MemoryBmp ImageFormat is null or something. Didn't you get this exception?
-
Compare picturebox.image with image from a resource fileDidn't work! This is what I got from your code example. "Tarning1" is one picture in the resource file. "bild" is the picture box name.
System.IO.MemoryStream ms1 = new System.IO.MemoryStream();
Bitmap pic1 = new Bitmap(bild.Image);
pic1.Save(ms1, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] byteArray1 = ms1.ToArray();System.IO.MemoryStream ms2 = new System.IO.MemoryStream();
Bitmap pic2 = DicePictures.Tarning1;
pic2.Save(ms2, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] byteArray2 = ms2.ToArray();if (byteArray1 == byteArray2)
Console.WriteLine("Equal");
else
Console.WriteLine("Not equal");Did I miss something?
-
Compare picturebox.image with image from a resource fileHave already tried, it didn't work =( Thanx anyway
-
Compare picturebox.image with image from a resource fileI have added 4 pictures to a resource file which I want to compare with the image in a picture box An example of what I want to do is:
if (pictureBox1.Image == resourceFile.Image1)
{
pictureBox1.Image = resourceFile.Image2;
}else
{
pictureBox1.Image = resourceFile.Image1;
}This code compiles but the else-statement always executes. How do I make this work?