예제 #1
0
        public static Bitmap ReturnDifferences(UnlockedBitmap unlockedA, UnlockedBitmap unlockedB)
        {
            Bitmap   result = new Bitmap(unlockedA.Bitmap.Width, unlockedA.Bitmap.Height, PixelFormat.Format32bppArgb);
            Graphics g      = BitmapFactory.CreateGraphics(result);

            g.Clear(Color.Transparent);
            g.Dispose();
            var unlockedRes = Unlock(result);
            int npixels     = unlockedA.Bitmap.Height * unlockedA.Data.Stride / 3;

            unsafe
            {
                byte *pA   = (byte *)unlockedA.Data.Scan0.ToPointer();
                byte *pB   = (byte *)unlockedB.Data.Scan0.ToPointer();
                int * pRes = (int *)unlockedRes.Data.Scan0.ToPointer();

                for (int i = 0; i < npixels; i++)
                {
                    if (pA[0] != pB[0] || pA[1] != pB[1] || pA[2] != pB[2])
                    {
                        pRes[i] = Color.Red.ToArgb();
                    }

                    pA += 3;
                    pB += 3;
                }
            }

            Lock(unlockedRes);
            return(result);
        }
예제 #2
0
 public static void Lock(UnlockedBitmap unlockedBmp, bool dispose = false)
 {
     unlockedBmp.Bitmap.UnlockBits(unlockedBmp.Data);
     if (dispose)
     {
         unlockedBmp.Bitmap.Dispose();
     }
 }
예제 #3
0
        public static bool ContainsDifferences(UnlockedBitmap unlockedA, Bitmap b, bool disposeIfNoDifferences = false)
        {
            bool hasDif;
            var  unlockedB = Unlock(b);

            hasDif = ContainsDifferences(unlockedA, unlockedB);

            Lock(unlockedB, !hasDif && disposeIfNoDifferences);
            return(hasDif);
        }
예제 #4
0
        public static Bitmap ReturnDifferences(UnlockedBitmap unlockedA, Bitmap b, bool dispose = false)
        {
            Bitmap result;
            var    unlockedB = Unlock(b);

            result = ReturnDifferences(unlockedA, unlockedB);

            Lock(unlockedB, dispose);
            return(result);
        }
예제 #5
0
        public static bool ContainsDifferences(UnlockedBitmap unlockedA, UnlockedBitmap unlockedB)
        {
            int npixels = unlockedA.Bitmap.Height * unlockedA.Data.Stride / 3;

            unsafe {
                byte *pA = (byte *)unlockedA.Data.Scan0.ToPointer();
                byte *pB = (byte *)unlockedB.Data.Scan0.ToPointer();

                for (int i = 0; i < npixels; i++)
                {
                    if (pA[0] != pB[0] || pA[1] != pB[1] || pA[2] != pB[2])
                    {
                        return(true);
                    }

                    pA += 3;
                    pB += 3;
                }
            }
            return(false);
        }
예제 #6
0
 public static void Dispose(UnlockedBitmap unlockedBmp)
 {
     unlockedBmp.Bitmap.Dispose();
 }