Trying to compare 2 pictureboxes. Are they the same. Thanks
Public
Shared Function ImagesAreTheSame(ByVal bmp1 _ As Bitmap, ByVal bmp2 As Bitmap) As Boolean 'If the images aren't the same size, quit If bmp1.Size.Width <> bmp2.Size.Width OrElse _bmp1.Size.Height <> bmp2.Size.Height
Then Return False Else 'Convert each image to a byte array '.NET.NET() Dim ic As System.Drawing.ImageConverter = _ New System.Drawing.ImageConverter Dim btImage1() As Byte = New Byte(1) {}btImage1 =
CType(ic.ConvertTo(bmp1, _btImage1.GetType()),
Byte()) Dim btImage2() As Byte = New Byte(1) {}btImage2 =
CType(ic.ConvertTo(bmp2, _btImage2.GetType()),
Byte()) 'The byte arrays may be different lengths if they 'contain different metadata, e.g. EXIF, TIFF tags If btImage1.Length <> btImage2.Length _ Then Return False Dim i As Integer For i = 0 To btImage1.Length - 1 If btImage1(i) <> btImage2(i) Then Return False Next Return True End If End Function
Help converting Function to C#
techuser
private
bool CompareBitmaps(Bitmap bmp1, Bitmap bmp2){
if ((bmp1.Size.Width != bmp2.Size.Width) || (bmp1.Size.Height != bmp2.Size.Height)) return false; else{
System.Drawing.
ImageConverter ic = new System.Drawing.ImageConverter(); byte[] btImage1 = new byte[2];btImage1 = (
byte[])ic.ConvertTo(bmp1, btImage1.GetType()); byte[] btImage2 = new byte[2];btImage2 = (
byte[])ic.ConvertTo(bmp2, btImage2.GetType()); if (btImage1.Length != btImage2.Length) return false; for (int i = 0; i < btImage1.Length; i++) if (btImage1}
}
Keeron Modi
public Boolean ImagesAreTheSame(Bitmap bmp1, Bitmap bmp2)
{
//If the images aren't the same size, quite if ((bmp1.Size.Width != bmp2.Size.Width) || (bmp1.Size.Height != bmp2.Size.Height)){
return false;}
else{
//Convert each image to a byte array //.NET.NET()System.Drawing.
ImageConverter ic = new System.Drawing.ImageConverter(); Byte btImage1 = new Byte(1);btImage1 = CType(ic.ConvertTo(bmp1, btImage1.GetType()), Byte());
Byte btImage2 = new Byte(1);btImage2 = CType(ic.ConvertTo(bmp2,btImage2.GetType()), Byte());
if (btImage1.Length != btImage2.Length) return False; int i; for (i = 0; i < btImage1.Length - 1; i++) if (btImage1(i)!= btImage2(i)) return False;}
shaktipravesh
{
if (bmp1.Size.Width != bmp2.Size.Width || bmp1.Size.Height != bmp2.Size.Height) {
return false;
} else {
System.Drawing.ImageConverter ic = new System.Drawing.ImageConverter();
byte[][0] btImage1 = new byte[1];
btImage1 = ((byte)(ic.ConvertTo(bmp1, btImage1.GetType())));
byte[][0] btImage2 = new byte[1];
btImage2 = ((byte)(ic.ConvertTo(bmp2, btImage2.GetType())));
if (btImage1.Length != btImage2.Length) {
return false;
}
int i;
for (int i = 0; i <= btImage1.Length - 1; i++) {
if (btImage1(i) != btImage2(i)) {
return false;
}
}
return true;
}
}
Abhinaba
Thanks,
Josh Lindenmuth
AdeptBlue
Tremint
Josh
Schneider
SuperSaiyanZero
public Boolean ImagesAreTheSame(Bitmap bmp1, Bitmap bmp2)
{
//If the images aren't the same size, quite
if ((bmp1.Size.Width <> bmp2.Size.Width) || (bmp1.Size.Height <> bmp2.Size.Height))
{
return false;
}
else
{
//Convert each image to a byte array
//.NET.NET()
System.Drawing.ImageConverter ic = new System.Drawing.ImageConverter();
.
.
.
etc.
Follow basic method above for converting rest of your code.
Hope this helps,
Josh
anup_am
no constructors, type does'nt exit, byte is a type but used like a variable....on and on.
I figured this was a good example of a "hairy" example to get into....maybe a little much...
homer jay