public void FilterTestBlackAndWhite()
        {
            //load the original bitmap
            bitmapOriginal = ImageUtils.loadOriginalPicture();

            //apply Image Filter filter
            Bitmap bitmapOriginalWithImageFilters = ImageFilters.BlackWhite(bitmapOriginal);

            //apply manually filter on the bitmap expected
            Bitmap bitmapExpected = bitmapOriginal;

            int   rgb;
            Color c;

            for (int y = 0; y < bitmapExpected.Height; y++)
            {
                for (int x = 0; x < bitmapExpected.Width; x++)
                {
                    c   = bitmapExpected.GetPixel(x, y);
                    rgb = (int)((c.R + c.G + c.B) / 3);
                    bitmapExpected.SetPixel(x, y, Color.FromArgb(rgb, rgb, rgb));
                }
            }

            //check if the pixel of the two images are the same
            bool result = ImageUtils.comparePixelImages(bitmapOriginalWithImageFilters, bitmapExpected);

            Assert.IsTrue(result);
        }
Beispiel #2
0
        public void extensionTest()
        {
            Bitmap imageFiltreeTest = ImageFilters.BlackWhite(imageInitiale);

            String extensionImageInitiale = Path.GetExtension(imageInitiale.ToString());
            String extensionImageFiltree  = Path.GetExtension(imageFiltreeTest.ToString());

            Assert.AreEqual(extensionImageInitiale, extensionImageFiltree);
        }
Beispiel #3
0
        public void pixelIntegrityTest()
        {
            Bitmap imageFiltree = ImageFilters.BlackWhite(imageInitiale);

            for (int x = 0; x < imageFiltree.Height; x++)
            {
                for (int y = 0; y < imageFiltree.Width; y++)
                {
                    Assert.AreEqual(imageInitiale.GetPixel(y, x), imageFiltree.GetPixel(y, x));
                }
            }
        }
Beispiel #4
0
        public void colorPixelTest()
        {
            Bitmap imageFiltreeTest = ImageFilters.BlackWhite(imageInitiale);

            for (int i = 0; i < imageFiltreeTest.Width; i++)
            {
                for (int j = 0; j < imageFiltreeTest.Height; j++)
                {
                    Color couleurPixelSouhaite = imageFiltreeBlackWhite.GetPixel(i, j);
                    Color couleurPixelTest     = imageFiltreeTest.GetPixel(i, j);

                    Assert.AreEqual(couleurPixelSouhaite, couleurPixelTest);
                }
            }
        }
Beispiel #5
0
        public void BlackWhiteTest()
        {
            // Custom image used for test
            Bitmap TestImg = new Bitmap(100, 100);
            // Method result for comparison
            Bitmap Result;

            for (int y = 0; y < TestImg.Height; y++)
            {
                for (int x = 0; x < TestImg.Width; x++)
                {
                    TestImg.SetPixel(x, y, Color.FromArgb(120, 90, 150));
                }
            }

            Result = ImageFilters.BlackWhite(TestImg);
            Assert.IsTrue(IsPixelColorEqual(Result));
        }
Beispiel #6
0
        public void sizeTest()
        {
            Bitmap imageFiltree = ImageFilters.BlackWhite(imageInitiale);

            Assert.AreEqual(imageInitiale.Size, imageFiltree.Size);
        }
 public override Bitmap Apply(Bitmap bitmap)
 {
     return(ImageFilters.BlackWhite(new Bitmap(bitmap)));
 }