本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
}
示例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);
}
}
}
示例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);
}