# Region determine whether the image is consistent ////// Determine whether the image is consistent //////Image 1///Image 2///
Consistent?
Public bool IsSameImg (Bitmap img, Bitmap bmp) {// if (img. width = bmp. width & img. height = bmp. height) {// lock image 1 to the memory BitmapData imgData_ I = img. lockBits (new Rectangle (0, 0, img. width, img. height), ImageLockMode. readOnly, PixelFormat. format24bppRgb); IntPtr ipr_ I = bytes; int length_ I = imgData_ I .Width * imgData_ I .Height * 3; byte [] imgValue_ I = new byte [length_ I]; Marshal. copy (ipr _ I, imgValue_ I, 0, length_ I); img. unlockBits (imgData_ I); // lock Image 2 to the memory BitmapData imgData_ B = img. lockBits (new Rectangle (0, 0, img. width, img. height), ImageLockMode. readOnly, PixelFormat. format24bppRgb); IntPtr ipr_ B = imgData_ B .Scan0; int length_ B = imgData_ B .Width * imgData_ B .Height * 3; byte [] imgValue_ B = new byte [length_ B]; Marshal. copy (ipr_ B, imgValue_ B, 0, length_ B); img. unlockBits (imgData_ B); // The length is not the same if (length_ I! = Length_ B) {return false;} else {// loop judgment value for (int I = 0; I <length_ I; I ++) {// inconsistent if (imgValue_ I [I]! = ImgValue_ B [I]) {return false ;}} return true ;}} else {return false ;}# endregion