示例#1
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);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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);
        }