Class that enables resizing of images
상속: IDisposable
예제 #1
0
파일: Crop.cs 프로젝트: 24hr/Clippy
        public void When_cropping_we_should_get_an_image_that_is_exactly_our_requested_size()
        {
            var original = GenerateTestImage(800, 600);

            var resized = new ResizeImage(original)
                .Crop()
                .ToSize(400, 300)
                .Save();

            resized.Width.Should().Be(400);
            resized.Height.Should().Be(300);
        }
예제 #2
0
파일: Pad.cs 프로젝트: 24hr/Clippy
        public void It_pads_to_exactly_requested_size()
        {
            var original = GenerateTestImage(800, 600);

            var resizedImage = new ResizeImage(original)
                .Pad(Color.Black)
                .ToSize(331, 418)
                .Save();

            resizedImage.Width.Should().Be(331);
            resizedImage.Height.Should().Be(418);
        }
예제 #3
0
파일: Pad.cs 프로젝트: 24hr/Clippy
        public void It_pads_with_the_correct_color()
        {
            var original = GenerateTestImage(800, 600, Color.Yellow);

            var resizedImage = new ResizeImage(original)
                .Pad(Color.Black)
                .ToSize(400, 600)
                .Save();

            resizedImage.GetPixel(0, 0).ToHex().Should().Be(Color.Black.ToHex());
            resizedImage.GetPixel(399, 599).ToHex().Should().Be(Color.Black.ToHex());
            resizedImage.GetPixel(0, 151).ToHex().Should().Be(Color.Yellow.ToHex());
            resizedImage.GetPixel(400, 449).ToHex().Should().Be(Color.Yellow.ToHex());
        }
예제 #4
0
파일: Constrain.cs 프로젝트: 24hr/Clippy
        public void It_calculates_constrain_correctly()
        {
            var original = GenerateTestImage(800, 600);

            var resizedImage = new ResizeImage(original)
                .Constrain()
                .ToSize(200, 200)
                .Save();

            resizedImage.Width.Should().Be(200);
            resizedImage.Height.Should().Be(150);

            resizedImage = new ResizeImage(original)
                .Constrain()
                .ToSize(465, 250)
                .Save();

            resizedImage.Width.Should().Be(333);
            resizedImage.Height.Should().Be(250);
        }