DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Compare Two Bitmap Objects

04.24.2007
| 4896 views |
  • submit to reddit
        
        private bool PicsIdentical(Bitmap bmp1, Bitmap bmp2)
        {
            bool retVal = true;

            if (bmp1.Size != bmp2.Size)
                retVal = false;
            else
            {
                for (int x = 0; x < bmp1.Width; x++)
                {
                    for (int y = 0; y < bmp1.Height; y++)
                    {
                        if (bmp1.GetPixel(x, y) != bmp2.GetPixel(x, y))
                        {
                            retVal = false;
                            break;
                        }
                    }
                }
            }
            return retVal;
        }