当前位置: 首页>>代码示例>>C#>>正文


C# WebImage.Resize方法代码示例

本文整理汇总了C#中WebImage.Resize方法的典型用法代码示例。如果您正苦于以下问题:C# WebImage.Resize方法的具体用法?C# WebImage.Resize怎么用?C# WebImage.Resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebImage的用法示例。


在下文中一共展示了WebImage.Resize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MultipleCombinedOperationsExecuteInRightOrder

        public void MultipleCombinedOperationsExecuteInRightOrder()
        {
            WebImage image = new WebImage(_JpgImageBytes);
            image.Resize(200, 100, preserveAspectRatio: true, preventEnlarge: true).RotateLeft();
            image.Crop(top: 10, right: 10).AddTextWatermark("plan9");

            Assert.Equal(90, image.Width);
            Assert.Equal(120, image.Height);
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:9,代码来源:WebImageTest.cs

示例2: ClonePreservesAllInformation

        public void ClonePreservesAllInformation()
        {
            WebImage image = new WebImage(_JpgImageBytes);
            image.Resize(200, 100, preserveAspectRatio: true, preventEnlarge: true).RotateLeft();

            // this should preserve list of transformations
            WebImage cloned = image.Clone();

            Assert.Equal(100, cloned.Width);
            Assert.Equal(130, cloned.Height);
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:11,代码来源:WebImageTest.cs

示例3: ResizePreventsEnlarge

        public void ResizePreventsEnlarge()
        {
            WebImage image = new WebImage(_JpgImageBytes);

            int height = image.Height;
            int width = image.Width;

            image.Resize(width * 2, height, preserveAspectRatio: true, preventEnlarge: true);
            Assert.Equal(width, image.Width);
            Assert.Equal(height, image.Height);
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:11,代码来源:WebImageTest.cs

示例4: ResizeAndRotateDoesOperationsInRightOrder

        public void ResizeAndRotateDoesOperationsInRightOrder()
        {
            WebImage image = new WebImage(_JpgImageBytes);
            image.Resize(200, 100, preserveAspectRatio: true, preventEnlarge: true).RotateLeft();

            Assert.Equal(100, image.Width);
            Assert.Equal(130, image.Height);
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:8,代码来源:WebImageTest.cs

示例5: ResizeThrowsOnIncorrectWidthOrHeight

        public void ResizeThrowsOnIncorrectWidthOrHeight()
        {
            WebImage image = new WebImage(_JpgImageBytes);

            Assert.ThrowsArgumentGreaterThan(
                () => image.Resize(-1, 100, preserveAspectRatio: true, preventEnlarge: true),
                "width",
                "0");

            Assert.ThrowsArgumentGreaterThan(
                () => image.Resize(100, -1, preserveAspectRatio: true, preventEnlarge: true),
                "height",
                "0");
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:14,代码来源:WebImageTest.cs

示例6: ResizePreservesFormat

        public void ResizePreservesFormat()
        {
            // Arrange
            WebImage image = new WebImage(_PngImageBytes);
            MemoryStream output = null;
            Action<string, byte[]> saveAction = (_, content) => { output = new MemoryStream(content); };

            // Act
            image.Resize(200, 100, preserveAspectRatio: true, preventEnlarge: true);

            // Assert
            Assert.Equal(image.ImageFormat, "png");
            image.Save(GetContext(), saveAction, @"x:\1.png", null, false);

            using (Image modified = Image.FromStream(output))
            {
                Assert.Equal(ImageFormat.Png, modified.RawFormat);
            }
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:19,代码来源:WebImageTest.cs

示例7: ResizePreservesResolution

        public void ResizePreservesResolution()
        {
            MemoryStream output = null;
            Action<string, byte[]> saveAction = (_, content) => { output = new MemoryStream(content); };

            WebImage image = new WebImage(_PngImageBytes);

            image.Resize(100, 50, preserveAspectRatio: true, preventEnlarge: true);

            image.Save(GetContext(), saveAction, @"x:\ResizePreservesResolution.jpg", "jpeg", forceWellKnownExtension: true);
            using (Image original = Image.FromStream(new MemoryStream(_PngImageBytes)))
            {
                using (Image modified = Image.FromStream(output))
                {
                    Assert.Equal(original.HorizontalResolution, modified.HorizontalResolution);
                    Assert.Equal(original.VerticalResolution, modified.VerticalResolution);
                }
            }
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:19,代码来源:WebImageTest.cs

示例8: ResizePreservesRatio

        public void ResizePreservesRatio()
        {
            WebImage image = new WebImage(_JpgImageBytes);

            image.Resize(200, 100, preserveAspectRatio: true, preventEnlarge: true);

            Assert.Equal(130, image.Width);
            Assert.Equal(100, image.Height);
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:9,代码来源:WebImageTest.cs


注:本文中的WebImage.Resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。