C # Quick way to determine whether two pictures are consistent

Source: Internet
Author: User
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 &LT;/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)!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.