C # Quick way to determine whether two pictures are consistent
#region to determine if the picture is consistent///<summary>////</summary>//<param name= "img" > Picture one </PARAM&G T <param name= "BMP" > Picture two </param>//<returns> consistent </returns> public bool Issameimg (Bitmap img , Bitmap BMP) {//Size consistent if (IMG). Width = = bmp. Width && img. Height = = bmp. Height) {//Lock the picture 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 the 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); The length is not the same if (length_i! = Length_b) {return false; } else {//cyclic judgment value for (int i = 0; i < length_i; i++) {//Inconsistent if (imgvalue_i[i]! = Imgvalue_b[i]) {RET Urn false; }} return true; }} else {return false; }} #endregion
The above is the C # to determine whether two images are consistent fast method content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!