本文整理汇总了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.");
}
示例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);
}
示例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));
}
示例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));
}
示例5: AddImageWatermarkThrowsOnNegativePadding
public void AddImageWatermarkThrowsOnNegativePadding()
{
WebImage watermark = new WebImage(_BmpImageBytes);
WebImage image = new WebImage(_JpgImageBytes);
Assert.ThrowsArgumentGreaterThanOrEqualTo(
() => image.AddImageWatermark(watermark, padding: -10),
"padding",
"0");
}
示例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);
}
示例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\".");
}
示例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\".");
}
示例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.");
}
示例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");
}
示例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);
}
示例12: AddImageWatermarkThrowsOnNullImage
public void AddImageWatermarkThrowsOnNullImage()
{
WebImage image = new WebImage(_JpgImageBytes);
Assert.ThrowsArgumentNull(
() => image.AddImageWatermark(watermarkImage: null),
"watermarkImage");
}
示例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);
}
示例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);
}
示例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);
}