Esempio n. 1
0
        public void ExtBitmapCopyToSquareCanvasTest()
        {
            // get the class through interface
            IBitmap bitmap = new ExtBitmap();

            // get an image and set a canvas width
            Bitmap originalBitmap = Properties.Resources.panda;
            int    canvasWidth    = 559;

            // run the method to copy the image to the suqare canvas
            bitmap.CopyToSquareCanvas(originalBitmap, canvasWidth);

            Assert.IsTrue(true);
        }
Esempio n. 2
0
        public void TestImageLaplacian3x3()
        {
            Bitmap testedBitmap;

            //Resize with the size of canvas
            testedBitmap = ExtBitmap.CopyToSquareCanvas(originalBitmapTest, 600);
            //send a photo to modify it
            testedBitmap = ExtBitmap.Laplacian3x3Filter(testedBitmap, false);

            //Retrieve the already modified photo
            Bitmap testBitmap = null;
            string FileName   = @"C:\Users\quent\Documents\GitHub\Image_Filtering_Detection\UnitTestImageDection\Laplacian3x3.png";

            StreamReader streamReader = new StreamReader(FileName);

            testBitmap = (Bitmap)Bitmap.FromStream(streamReader.BaseStream);
            streamReader.Close();

            //comparison
            Assert.AreEqual(testBitmap.GetPixel(2, 2), testedBitmap.GetPixel(2, 2));
        }
Esempio n. 3
0
        public void TestCopyToSquareCanvasWithSamllerCanvas()
        {
            //Initialize sizes
            float bpmHeight  = 200f;
            float bpmWidth   = 200f;
            int   canvasSize = 100;

            //Determine the ratio for expected results
            float ratio = bpmWidth / canvasSize;

            //Send bitmap with height, width and canvas to tested method
            Bitmap bpmAfterMethodCanvas = ExtBitmap.CopyToSquareCanvas(new Bitmap((int)bpmWidth, (int)bpmHeight), canvasSize);

            //All expected sizes
            float bpmWidthExpected  = canvasSize;
            float bpmHeightExpected = bpmHeight / ratio;
            //Tested sizes
            float widthResult  = (float)bpmAfterMethodCanvas.Width;
            float heigthResult = (float)bpmAfterMethodCanvas.Height;

            //Compare values
            Assert.AreEqual(bpmWidthExpected, widthResult);
            Assert.AreEqual(bpmHeightExpected, heigthResult);
        }