Пример #1
0
        public void TestFlipVertical()
        {
            const string outputFilePath = "../../Output/Flip-Vertical.jpg";

            var thisImage = new NetImage();

            thisImage.LoadImage("../../Resources/1024x768.png");
            thisImage.Filename = outputFilePath;
            thisImage.FlipImage(NetImage.FlipDirections.Vertical);
            thisImage.SaveImage();

            int width, height;

            thisImage.GetImageFileSize(outputFilePath, out width, out height);

            Assert.AreEqual(1024, width);
            Assert.AreEqual(768, height);
        }
Пример #2
0
        public void TestRotate180Degrees()
        {
            const string outputFilePath = "../../Output/Rotate-180_degrees.jpg";

            var thisImage = new NetImage();

            thisImage.LoadImage("../../Resources/1024x768.png");
            thisImage.Filename = outputFilePath;
            thisImage.RotateImage(180);
            thisImage.SaveImage();

            int width, height;

            thisImage.GetImageFileSize(outputFilePath, out width, out height);

            Assert.AreEqual(1024, width);
            Assert.AreEqual(768, height);
        }
Пример #3
0
        public void TestCropImage()
        {
            const string outputFilePath = "../../Output/CropImage.jpg";

            var thisImage = new NetImage();

            thisImage.LoadImage("../../Resources/1024x768.png");
            thisImage.Filename = outputFilePath;
            thisImage.CropImage(10, 50, 800, 600);
            thisImage.SaveImage();

            int width, height;

            thisImage.GetImageFileSize(outputFilePath, out width, out height);

            Assert.AreEqual(800, width);
            Assert.AreEqual(600, height);
        }
Пример #4
0
        public void TestResizePortraitWithoutConstraint()
        {
            const string outputFilePath = "../../Output/Resize-Variant_aspect_ratio_portrait-Unconstrained.jpg";

            var thisImage = new NetImage();

            thisImage.LoadImage("../../Resources/900x1440.png");
            thisImage.Filename        = outputFilePath;
            thisImage.ConstrainResize = false;
            thisImage.Resize(800, 600);
            thisImage.SaveImage();

            int width, height;

            thisImage.GetImageFileSize(outputFilePath, out width, out height);

            Assert.AreEqual(800, width);
            Assert.AreEqual(600, height);
        }
Пример #5
0
        public void TestResizeLandscapeWithConstraint()
        {
            const string outputFilePath = "../../Output/Resize-Variant_aspect_ratio_landscape-Constrained.jpg";

            var thisImage = new NetImage();

            thisImage.LoadImage("../../Resources/1440x900.png");
            thisImage.Filename        = outputFilePath;
            thisImage.ConstrainResize = true;
            thisImage.Resize(800, 600);
            thisImage.SaveImage();

            int width, height;

            thisImage.GetImageFileSize(outputFilePath, out width, out height);

            Assert.AreEqual(800, width);
            Assert.AreEqual(600, height);
        }
Пример #6
0
        public void TestResizeSameAspectRatioWithConstraint()
        {
            const string outputFilePath = "../../Output/Resize-Same_aspect_ratio-Constrained.jpg";

            var thisImage = new NetImage();

            thisImage.LoadImage("../../Resources/1024x768.png");
            thisImage.Filename        = outputFilePath;
            thisImage.ConstrainResize = true;
            thisImage.Resize(800, 600);
            thisImage.SaveImage();

            int width, height;

            thisImage.GetImageFileSize(outputFilePath, out width, out height);

            Assert.AreEqual(800, width);
            Assert.AreEqual(600, height);
        }
Пример #7
0
        public void TestRotate90DegreesWithCrop()
        {
            const string outputFilePath = "../../Output/Rotate-90_degrees_with_crop.jpg";
            int          originalWidth  = 0;
            int          originalHeight = 0;

            var thisImage = new NetImage();

            thisImage.LoadImage("../../Resources/1024x768.png");
            thisImage.GetImageSize(out originalWidth, out originalHeight);
            thisImage.Filename = outputFilePath;
            thisImage.RotateImage(90);
            thisImage.ConstrainResize = true;
            thisImage.Resize(originalWidth, originalHeight);
            thisImage.SaveImage();

            int width, height;

            thisImage.GetImageFileSize(outputFilePath, out width, out height);

            Assert.AreEqual(originalWidth, width);
            Assert.AreEqual(originalHeight, height);
        }