This article mainly introduces C # to determine whether two pictures are consistent fast method, the need for friends can refer to the following
The code is as follows: #region to determine whether the picture is consistent ///<summary> ///to determine whether the picture is consistent ///</summary> ///<param name= " IMG "> Picture one </param> ///<param name=" BMP "> Picture two </param> ///<returns> is consistent </ returns> public bool Issameimg (Bitmap img, Bitmap BMP) { //size consistent if (IMG. Width = = bmp. Width && img. Height = = bmp. Height) { //Lock picture one to memory BitmapData imgdata_i = img. LockBits (New Rectangle (0, 0, IMG). Width, IMG. Height), imagelockmode.readonly, Pixelformat.format24bpprgb); IntPtr ipr_i = imgdata_i.scan0; 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 picture two to 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); //Length not identical if (length_i!= length_b) { return false; } Else { //Cycle judgment for (int i = 0; i < length_i i++) { /Inconsistent if (imgvalue_i[i)!= Imgvalue _b[i]) { return false; } } return true; } } else -{ return Fals e; } } #endregion