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


C# WebImage.AddImageWatermark方法代码示例

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


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

示例1: AddImageWatermarkWithFileNameThrowsExceptionWhenWatermarkFilePathIsEmpty

 public void AddImageWatermarkWithFileNameThrowsExceptionWhenWatermarkFilePathIsEmpty()
 {
     var context = GetContext();
     WebImage image = new WebImage(_BmpImageBytes);
     Assert.ThrowsArgument(
         () => image.AddImageWatermark(context, s => _JpgImageBytes, watermarkImageFilePath: null, width: 0, height: 0, horizontalAlign: "Right", verticalAlign: "Bottom", opacity: 100, padding: 5),
         "filePath",
         "Value cannot be null or an empty string.");
 }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:9,代码来源:WebImageTest.cs

示例2: CanAddImageWatermarkWithFileName

        public void CanAddImageWatermarkWithFileName()
        {
            // Arrange
            var context = GetContext();
            WebImage image = new WebImage(_BmpImageBytes);
            WebImage watermark = new WebImage(_JpgImageBytes);

            // Act
            var watermarkedWithImageArgument = image.AddImageWatermark(watermark).GetBytes();
            var watermarkedWithFilePathArgument = image.AddImageWatermark(context, (name) => _JpgImageBytes, @"x:\jpegimage.jpg", width: 0, height: 0, horizontalAlign: "Right", verticalAlign: "Bottom", opacity: 100, padding: 5).GetBytes();

            Assert.Equal(watermarkedWithImageArgument, watermarkedWithFilePathArgument);
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:13,代码来源:WebImageTest.cs

示例3: AddImageWatermarkWithFileNameThrowsExceptionWhenWatermarkDirectoryDoesNotExist

        public void AddImageWatermarkWithFileNameThrowsExceptionWhenWatermarkDirectoryDoesNotExist()
        {
            var context = GetContext();
            WebImage image = new WebImage(_BmpImageBytes);

            Assert.Throws<DirectoryNotFoundException>(
                () => image.AddImageWatermark(context, s => { throw new DirectoryNotFoundException(); }, @"x:\path\does\not\exist", width: 0, height: 0, horizontalAlign: "Right", verticalAlign: "Bottom", opacity: 100, padding: 5));
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:8,代码来源:WebImageTest.cs

示例4: AddImageWatermarkWithFileNameThrowsExceptionWhenWatermarkFileDoesNotExist

 public void AddImageWatermarkWithFileNameThrowsExceptionWhenWatermarkFileDoesNotExist()
 {
     var context = GetContext();
     WebImage image = new WebImage(_BmpImageBytes);
     Assert.Throws<FileNotFoundException>(
         () => image.AddImageWatermark(context, s => { throw new FileNotFoundException(); }, @"x:\there-is-no-file.jpg", width: 0, height: 0, horizontalAlign: "Right", verticalAlign: "Bottom", opacity: 100, padding: 5));
 }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:7,代码来源:WebImageTest.cs

示例5: AddImageWatermarkThrowsOnNegativePadding

        public void AddImageWatermarkThrowsOnNegativePadding()
        {
            WebImage watermark = new WebImage(_BmpImageBytes);
            WebImage image = new WebImage(_JpgImageBytes);

            Assert.ThrowsArgumentGreaterThanOrEqualTo(
                () => image.AddImageWatermark(watermark, padding: -10),
                "padding",
                "0");
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:10,代码来源:WebImageTest.cs

示例6: AddImageWatermarkDoesNotChangeImageIfWatermarkIsTooBig

        public void AddImageWatermarkDoesNotChangeImageIfWatermarkIsTooBig()
        {
            WebImage watermark = new WebImage(_JpgImageBytes);
            WebImage image = new WebImage(_BmpImageBytes);
            byte[] originalBytes = image.GetBytes("jpg");

            // This will use original watermark image dimensions which is bigger than the target image.
            image.AddImageWatermark(watermark);
            byte[] watermarkedBytes = image.GetBytes("jpg");

            Assert.Equal(originalBytes, watermarkedBytes);
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:12,代码来源:WebImageTest.cs

示例7: AddImageWatermarkThrowsOnIncorrectHorizontalAlignment

        public void AddImageWatermarkThrowsOnIncorrectHorizontalAlignment()
        {
            WebImage watermark = new WebImage(_BmpImageBytes);
            WebImage image = new WebImage(_JpgImageBytes);

            Assert.Throws<ArgumentException>(
                () => image.AddImageWatermark(watermark, horizontalAlign: "horizontal"),
                "The \"horizontalAlign\" value is invalid. Valid values are: \"Right\", \"Left\", and \"Center\".");
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:9,代码来源:WebImageTest.cs

示例8: AddImageWatermarkThrowsOnIncorrectVerticalAlignment

        public void AddImageWatermarkThrowsOnIncorrectVerticalAlignment()
        {
            WebImage watermark = new WebImage(_BmpImageBytes);
            WebImage image = new WebImage(_JpgImageBytes);

            Assert.Throws<ArgumentException>(
                () => image.AddImageWatermark(watermark, verticalAlign: "vertical"),
                "The \"verticalAlign\" value is invalid. Valid values are: \"Top\", \"Bottom\", and \"Middle\".");
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:9,代码来源:WebImageTest.cs

示例9: AddImageWatermarkThrowsWhenOpacityIsIncorrect

        public void AddImageWatermarkThrowsWhenOpacityIsIncorrect()
        {
            WebImage watermark = new WebImage(_BmpImageBytes);
            WebImage image = new WebImage(_JpgImageBytes);

            Assert.ThrowsArgumentOutOfRange(() => image.AddImageWatermark(watermark, opacity: -1), "opacity", "Value must be between 0 and 100.");

            Assert.ThrowsArgumentOutOfRange(() => image.AddImageWatermark(watermark, opacity: 120), "opacity", "Value must be between 0 and 100.");
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:9,代码来源:WebImageTest.cs

示例10: AddImageWatermarkThrowsOnNegativeDimensions

        public void AddImageWatermarkThrowsOnNegativeDimensions()
        {
            WebImage watermark = new WebImage(_BmpImageBytes);
            WebImage image = new WebImage(_JpgImageBytes);

            Assert.ThrowsArgumentGreaterThanOrEqualTo(
                () => image.AddImageWatermark(watermark, width: -1),
                "width",
                "0");

            Assert.ThrowsArgumentGreaterThanOrEqualTo(
                () => image.AddImageWatermark(watermark, height: -1),
                "height",
                "0");
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:15,代码来源:WebImageTest.cs

示例11: AddImageWatermarkThrowsWhenJustOneDimensionIsZero

        public void AddImageWatermarkThrowsWhenJustOneDimensionIsZero()
        {
            WebImage watermark = new WebImage(_BmpImageBytes);
            WebImage image = new WebImage(_JpgImageBytes);

            string message = "Watermark width and height must both be positive or both be zero.";
            Assert.Throws<ArgumentException>(
                () => image.AddImageWatermark(watermark, width: 0, height: 22), message);

            Assert.Throws<ArgumentException>(
                () => image.AddImageWatermark(watermark, width: 100, height: 0), message);
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:12,代码来源:WebImageTest.cs

示例12: AddImageWatermarkThrowsOnNullImage

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

            Assert.ThrowsArgumentNull(
                () => image.AddImageWatermark(watermarkImage: null),
                "watermarkImage");
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:8,代码来源:WebImageTest.cs

示例13: AddImageWatermarkDoesNotChangeWatermarkImage

        public void AddImageWatermarkDoesNotChangeWatermarkImage()
        {
            WebImage watermark = new WebImage(_BmpImageBytes);
            WebImage image = new WebImage(_JpgImageBytes);
            image.AddImageWatermark(watermark, width: 54, height: 22, horizontalAlign: "LEFT", verticalAlign: "top", opacity: 50, padding: 10);

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

示例14: CanAddTextAndImageWatermarks

        public void CanAddTextAndImageWatermarks()
        {
            WebImage watermark = new WebImage(_BmpImageBytes);
            WebImage image = new WebImage(_JpgImageBytes);
            image.AddImageWatermark(watermark, horizontalAlign: "LEFT", verticalAlign: "top", opacity: 30, padding: 10);
            image.AddTextWatermark("plan9");

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

示例15: AddImageWatermarkPreservesImageDimension

        public void AddImageWatermarkPreservesImageDimension()
        {
            WebImage watermark = new WebImage(_BmpImageBytes);
            WebImage image = new WebImage(_JpgImageBytes);
            image.AddImageWatermark(watermark, horizontalAlign: "LEFT", verticalAlign: "top", opacity: 50, padding: 10);

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


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