Click here to Skip to main content
15,895,812 members
Articles / Programming Languages / C#

Using Clipboard C# 4.0 (Wrapper inside)

Rate me:
Please Sign up or sign in to vote.
4.67/5 (3 votes)
2 Oct 2012CPOL1 min read 26.6K   1.2K   16  
Library that manages all objects entering and leaving the Windows clipboard.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading.Tasks;

namespace D.Net.Clipboard
{
    public static class ImagesComparer
    {
        public static bool Equals(Image first, Image second)
        {
            if (first == null || second == null) return false;
            if (first.Width != second.Width) return false;
            if (first.Height != second.Height) return false;
            if (first.RawFormat.Guid != second.RawFormat.Guid) return false;
            if (first.PixelFormat != second.PixelFormat) return false;
            bool ok = true;
            for (int i = 0; i < first.Width;  i++)
            {
                for(int j = 0; j < first.Height; j++)
                {
                    String img1_ref = ((Bitmap)first).GetPixel(i, j).ToString();
                    String img2_ref = ((Bitmap)second).GetPixel(i, j).ToString();
                    if (img1_ref != img2_ref)
                    {
                        ok = false;
                    }
                }
            }
            return ok;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) D.Net Solution
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions