Class WebPImage
名称: Aspose.Imaging.FileFormats.Webp 收藏: Aspose.Imaging.dll (25.4.0)
使用我们的 API 操纵 WebP 拉斯特图像,使用其现代功能无损和无损压缩,以减少文件大小,确保最佳图像质量。轻松处理扩展文件格式、动画和阿尔法频道,同时轻松处理更新尺寸,相对重复,挖掘,旋转,应用过滤器,调整图像参数,并转换到其他图像格式为多元化网页图像优化
[JsonObject(MemberSerialization.OptIn)]
public sealed class WebPImage : RasterCachedMultipageImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImageExt, IMultipageImage
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← RasterImage ← RasterCachedImage ← RasterCachedMultipageImage ← WebPImage
Implements
IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IHasXmpData , IHasMetadata , IMultipageImageExt , IMultipageImage
继承人
RasterCachedMultipageImage.AdjustBrightness(int) , RasterCachedMultipageImage.AdjustContrast(float) , RasterCachedMultipageImage.AdjustGamma(float, float, float) , RasterCachedMultipageImage.AdjustGamma(float) , RasterCachedMultipageImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedMultipageImage.BinarizeFixed(byte) , RasterCachedMultipageImage.BinarizeBradley(double, int) , RasterCachedMultipageImage.BinarizeBradley(double) , RasterCachedMultipageImage.BinarizeOtsu() , RasterCachedMultipageImage.Crop(Rectangle) , RasterCachedMultipageImage.Crop(int, int, int, int) , RasterCachedMultipageImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedMultipageImage.Grayscale() , RasterCachedMultipageImage.NormalizeHistogram() , RasterCachedMultipageImage.Rotate(float, bool, Color) , RasterCachedMultipageImage.RotateFlip(RotateFlipType) , RasterCachedMultipageImage.RotateFlipAll(RotateFlipType) , RasterCachedMultipageImage.Resize(int, int, ResizeType) , RasterCachedMultipageImage.Resize(int, int, ImageResizeSettings) , RasterCachedMultipageImage.ResizeWidthProportionally(int, ResizeType) , RasterCachedMultipageImage.ResizeHeightProportionally(int, ResizeType) , RasterCachedMultipageImage.ReplaceColor(int, byte, int) , RasterCachedMultipageImage.ReplaceNonTransparentColors(int) , RasterCachedMultipageImage.Filter(Rectangle, FilterOptionsBase) , RasterCachedMultipageImage.NormalizeAngle(bool, Color) , RasterCachedMultipageImage.CacheData() , RasterCachedMultipageImage.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , RasterCachedMultipageImage.Height , RasterCachedMultipageImage.Width , RasterCachedMultipageImage.BitsPerPixel , RasterCachedMultipageImage.IsCached , RasterCachedMultipageImage.PageCount , RasterCachedMultipageImage.Pages , RasterCachedMultipageImage.HasAlpha , RasterCachedMultipageImage.HasTransparentColor , RasterCachedMultipageImage.ImageOpacity , RasterCachedMultipageImage.BackgroundColor , RasterCachedMultipageImage.XmpData , RasterCachedMultipageImage.PageExportingAction , RasterCachedImage.CacheData() , RasterCachedImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedImage.Resize(int, int, ResizeType) , RasterCachedImage.Resize(int, int, ImageResizeSettings) , RasterCachedImage.RotateFlip(RotateFlipType) , RasterCachedImage.Rotate(float, bool, Color) , RasterCachedImage.Crop(Rectangle) , RasterCachedImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedImage.Grayscale() , RasterCachedImage.NormalizeHistogram() , RasterCachedImage.BinarizeFixed(byte) , RasterCachedImage.BinarizeOtsu() , RasterCachedImage.BinarizeBradley(double, int) , RasterCachedImage.BinarizeBradley(double) , RasterCachedImage.AdjustBrightness(int) , RasterCachedImage.AdjustContrast(float) , RasterCachedImage.AdjustGamma(float, float, float) , RasterCachedImage.AdjustGamma(float) , RasterCachedImage.IsCached , RasterImage.RemoveMetadata() , RasterImage.Save(Stream, ImageOptionsBase, Rectangle) , RasterImage.GetModifyDate(bool) , RasterImage.Dither(DitheringMethod, int) , RasterImage.Dither(DitheringMethod, int, IColorPalette) , RasterImage.GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings) , RasterImage.GetDefaultArgb32Pixels(Rectangle) , RasterImage.GetDefaultRawData(Rectangle, RawDataSettings) , RasterImage.GetArgb32Pixel(int, int) , RasterImage.GetPixel(int, int) , RasterImage.SetArgb32Pixel(int, int, int) , RasterImage.SetPixel(int, int, Color) , RasterImage.ReadScanLine(int) , RasterImage.ReadArgb32ScanLine(int) , RasterImage.WriteScanLine(int, Color[]) , RasterImage.WriteArgb32ScanLine(int, int[]) , RasterImage.LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.LoadPartialPixels(Rectangle, IPartialPixelLoader) , RasterImage.LoadArgb32Pixels(Rectangle) , RasterImage.LoadArgb64Pixels(Rectangle) , RasterImage.LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader) , RasterImage.LoadPixels(Rectangle) , RasterImage.LoadCmykPixels(Rectangle) , RasterImage.LoadCmyk32Pixels(Rectangle) , RasterImage.LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.SaveRawData(byte[], int, Rectangle, RawDataSettings) , RasterImage.SaveArgb32Pixels(Rectangle, int[]) , RasterImage.SavePixels(Rectangle, Color[]) , RasterImage.SaveCmykPixels(Rectangle, CmykColor[]) , RasterImage.SaveCmyk32Pixels(Rectangle, int[]) , RasterImage.SetResolution(double, double) , RasterImage.SetPalette(IColorPalette, bool) , RasterImage.Resize(int, int, ImageResizeSettings) , RasterImage.Rotate(float, bool, Color) , RasterImage.Rotate(float) , RasterImage.BinarizeFixed(byte) , RasterImage.BinarizeOtsu() , RasterImage.BinarizeBradley(double) , RasterImage.BinarizeBradley(double, int) , RasterImage.Blend(Point, RasterImage, Rectangle, byte) , RasterImage.Blend(Point, RasterImage, byte) , RasterImage.Grayscale() , RasterImage.NormalizeHistogram() , RasterImage.AdjustBrightness(int) , RasterImage.AdjustContrast(float) , RasterImage.AdjustGamma(float, float, float) , RasterImage.AdjustGamma(float) , RasterImage.GetSkewAngle() , RasterImage.NormalizeAngle() , RasterImage.NormalizeAngle(bool, Color) , RasterImage.Filter(Rectangle, FilterOptionsBase) , RasterImage.ReplaceColor(Color, byte, Color) , RasterImage.ReplaceColor(int, byte, int) , RasterImage.ReplaceNonTransparentColors(Color) , RasterImage.ReplaceNonTransparentColors(int) , RasterImage.ToBitmap() , RasterImage.PremultiplyComponents , RasterImage.UseRawData , RasterImage.UpdateXmpData , RasterImage.XmpData , RasterImage.RawIndexedColorConverter , RasterImage.RawCustomColorConverter , RasterImage.RawFallbackIndex , RasterImage.RawDataSettings , RasterImage.UsePalette , RasterImage.RawDataFormat , RasterImage.RawLineSize , RasterImage.IsRawDataAvailable , RasterImage.HorizontalResolution , RasterImage.VerticalResolution , RasterImage.HasTransparentColor , RasterImage.HasAlpha , RasterImage.TransparentColor , RasterImage.ImageOpacity , Image.CanLoad(string) , Image.CanLoad(string, LoadOptions) , Image.CanLoad(Stream) , Image.CanLoad(Stream, LoadOptions) , Image.Create(ImageOptionsBase, int, int) , Image.Create(Image[]) , Image.Create(MultipageCreateOptions) , Image.Create(string[], bool) , Image.Create(string[]) , Image.Create(Image[], bool) , Image.GetFileFormat(string) , Image.GetFileFormat(Stream) , Image.GetFittingRectangle(Rectangle, int, int) , Image.GetFittingRectangle(Rectangle, int[], int, int) , Image.Load(string, LoadOptions) , Image.Load(string) , Image.Load(Stream, LoadOptions) , Image.Load(Stream) , Image.GetProportionalWidth(int, int, int) , Image.GetProportionalHeight(int, int, int) , Image.RemoveMetadata() , Image.CanSave(ImageOptionsBase) , Image.Resize(int, int) , Image.Resize(int, int, ResizeType) , Image.Resize(int, int, ImageResizeSettings) , Image.GetDefaultOptions(object[]) , Image.GetOriginalOptions() , Image.ResizeWidthProportionally(int) , Image.ResizeHeightProportionally(int) , Image.ResizeWidthProportionally(int, ResizeType) , Image.ResizeHeightProportionally(int, ResizeType) , Image.ResizeWidthProportionally(int, ImageResizeSettings) , Image.ResizeHeightProportionally(int, ImageResizeSettings) , Image.RotateFlip(RotateFlipType) , Image.Rotate(float) , Image.Crop(Rectangle) , Image.Crop(int, int, int, int) , Image.Save() , Image.Save(string) , Image.Save(string, ImageOptionsBase) , Image.Save(string, ImageOptionsBase, Rectangle) , Image.Save(Stream, ImageOptionsBase) , Image.Save(Stream, ImageOptionsBase, Rectangle) , Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , Image.SetPalette(IColorPalette, bool) , Image.BitsPerPixel , Image.Bounds , Image.Container , Image.Height , Image.Palette , Image.UsePalette , Image.Size , Image.Width , Image.InterruptMonitor , Image.BufferSizeHint , Image.AutoAdjustPalette , Image.HasBackgroundColor , Image.FileFormat , Image.BackgroundColor , DataStreamSupporter.CacheData() , DataStreamSupporter.Save() , DataStreamSupporter.Save(Stream) , DataStreamSupporter.Save(string) , DataStreamSupporter.Save(string, bool) , DataStreamSupporter.DataStreamContainer , DataStreamSupporter.IsCached , DisposableObject.Dispose() , DisposableObject.Disposed , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
此示例显示如何从文件上加载 WebP 图像并将其保存到 PNG。
string dir = "c:\\temp\\";
// Load a WebP image from a file.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(dir + "test.webp"))
{
// Save to PNG
// Note that only the active frame will be stored to PNG, since PNG is not a multi-page format.
webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Constructors
网页图像(Stream)
启动 Aspose.Imaging.FileFormats.Webp.WebPImage 类的新例子,启动从提供的流源. 使用此构建器无缝创建 WebP图像对象直接从电流,可有效处理和操纵WebP 图像数据在您的应用程序中。
public WebPImage(Stream stream)
Parameters
stream
Stream
流 WebP 图像。
Examples
此示例显示如何从文件流中加载 WebP 图像并将其保存到 PNG。
string dir = "c:\\temp\\";
// Load a WebP image from a file stream.
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "test.webp"))
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(stream))
{
// Save to PNG
// Note that only the active frame will be stored to PNG, since PNG is not a multi-page format.
webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
网页图像(流量, LoadOptions)
创建一个新的例子 Aspose.Imaging.FileFormats.Webp.WebPImage 类使用流和具体的加载选项,使 WebP 图像数据的多元化处理方便。插入此构建器以无缝启动 WebP 图像对象流量同时根据您的应用程序所需定制加载参数。
public WebPImage(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
流 WebP 图像。
loadOptions
LoadOptions
负载选项。
网页图像(线条)
启动 Aspose.Imaging.FileFormats.Webp.WebPImage 类的新例,启动从提供的文件来源. 使用此构建器无缝创建 WebP图像对象直接从文件,简化加载过程和在您的应用程序中操纵 WebP 图像数据。
public WebPImage(string path)
Parameters
path
string
路径到文件 WebP 图像
Examples
此示例显示如何从文件上加载 WebP 图像并将其保存到 PNG。
string dir = "c:\\temp\\";
// Load a WebP image from a file.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(dir + "test.webp"))
{
// Save to PNG
// Note that only the active frame will be stored to PNG, since PNG is not a multi-page format.
webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
网页图像(字符串, LoadOptions)
创建一个新的例子 Aspose.Imaging.FileFormats.Webp.WebPImage 类,使用一个文件和具体的加载选项,使 WebP 图像数据的灵活处理方便。这个构建器可以无缝地从文件中启动 WebP 图像对象根据您的应用程序的要求定制加载参数。
public WebPImage(string path, LoadOptions loadOptions)
Parameters
path
string
路径到文件 WebP 图像
loadOptions
LoadOptions
负载选项。
网页图像(RasterImage)
启动 Aspose.Imaging.FileFormats.Webp.WebPImage 类的新例子,启动从提供的 rasterImage 对象. 该构建器允许无缝将拉斯特图像转换为 WebP 格式,可有效处理和在您的应用程序中处理图像数据。
public WebPImage(RasterImage rasterImage)
Parameters
rasterImage
RasterImage
拉斯特图像。
Examples
此示例显示如何从另一个拉斯特图像中创建 WebP 图像。
string dir = "c:\\temp\\";
// Load a PNG image of 100x100 px.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100))
{
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);
// Fill the entire image in red.
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
graphics.FillRectangle(brush, pngImage.Bounds);
// Create a WebP image based on the PNG image.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(pngImage))
{
// Save to a WebP file with default options
webPImage.Save(dir + "output.webp", new Aspose.Imaging.ImageOptions.WebPOptions());
}
}
网页图像(拉斯特图像,LoadOptions)
创建 Aspose.Imaging.FileFormats.Webp.WebPImage 类的新例子,使用 rasterImage 对象和具体的负载选项,可灵活处理图像数据。构建器可以从拉斯特图像中无缝启动 WebP 图像对象根据您的应用程序的要求定制加载参数。
public WebPImage(RasterImage rasterImage, LoadOptions loadOptions)
Parameters
rasterImage
RasterImage
拉斯特图像。
loadOptions
LoadOptions
负载选项。
网页图像(int, int, WebPOptions)
立即启动 Aspose.Imaging.FileFormats.Webp.WebPImage 类的新例子图像的指定宽度和高度尺寸. 该构建器允许创建白色 WebP 图像,为后续图像提供基础操作和内容生成在您的应用程序内。
public WebPImage(int width, int height, WebPOptions options)
Parameters
width
int
图像宽度
height
int
图像高度。
options
WebPOptions
选项的。
Examples
此示例表明如何创建 WebP 图像,使用从扫描中指定的选项。
string dir = "c:\\temp\\";
Aspose.Imaging.ImageOptions.WebPOptions createOptions = new Aspose.Imaging.ImageOptions.WebPOptions();
createOptions.Lossless = true;
createOptions.Quality = 100f;
//createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dir + "output.webp");
// Create a WebP image of 100x100 px.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
{
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(webPImage);
// Fill the entire image in red.
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
graphics.FillRectangle(brush, webPImage.Bounds);
// Save to a WebP file
webPImage.Save(dir + "output.webp");
}
此示例显示如何使用指定的选项创建多框动画 WebP 图像。
string dir = "c:\\temp\\";
Aspose.Imaging.ImageOptions.WebPOptions createOptions = new Aspose.Imaging.ImageOptions.WebPOptions();
createOptions.Lossless = true;
createOptions.Quality = 100f;
createOptions.AnimBackgroundColor = (uint)Aspose.Imaging.Color.Gray.ToArgb();
// The default frame plus 36 + 36 additional frames.
createOptions.AnimLoopCount = 36 + 36 + 1;
// Create a WebP image of 100x100 px.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
{
// The first circle is red
Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
// The second circle is black
Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);
// Gradually inscrease the angle of the red arc shape.
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
graphics.FillPie(brush1, block.Bounds, 0, angle);
webPImage.AddBlock(block);
}
// Gradually inscrease the angle of the black arc and wipe out the red arc.
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
graphics.FillPie(brush2, block.Bounds, 0, angle);
graphics.FillPie(brush1, block.Bounds, angle, 360 - angle);
webPImage.AddBlock(block);
}
// Save to a WebP file
webPImage.Save(dir + "output.webp");
}
网页图像(int, int, WebPOptions, LoadOptions)
创建一个新的例子 Aspose.Imaging.FileFormats.Webp.WebPImage 类与一个空图像和指定此构建器允许启动 WebP 图像与可自定义的加载参数,提供图像创建的灵活性,以及在您的应用中进行操纵。
public WebPImage(int width, int height, WebPOptions options, LoadOptions loadOptions)
Parameters
width
int
图像宽度
height
int
图像高度。
options
WebPOptions
选项的。
loadOptions
LoadOptions
负载选项。
Properties
FileFormat
访问与图像相关的文件格式值,提供信息关于图像存储的格式. 使用此属性来确定图像的文件格式,方便兼容性检查和在您的应用程序内进行格式特定的处理。
public override FileFormat FileFormat { get; }
财产价值
HasAlpha
记录图像是否包含一个阿尔法频道,表明透明度信息. 使用此属性来确定图像是否包括透明度,以便适当处理和处理在您的应用程序内进行阿尔法相关操作。
public override bool HasAlpha { get; }
财产价值
Examples
下面的示例上传了WEBP图像,并打印了关于原始数据格式和阿尔法频道的信息。
string dir = "c:\\temp\\";
string fileName = dir + "sample.webp";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName))
{
Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (Aspose.Imaging.FileFormats.Webp.WebPImage)image;
// If the active TIFF frame has alpha channel, then the entire TIFF image is considered to have alpha channel.
System.Console.WriteLine("ImageFile={0}, FileFormat={1}, HasAlpha={2}", fileName, webpImage.RawDataFormat, webpImage.HasAlpha);
int i = 0;
foreach (Aspose.Imaging.FileFormats.Webp.IFrame frame in webpImage.Blocks)
{
Aspose.Imaging.FileFormats.Webp.WebPFrameBlock frameBlock = frame as Aspose.Imaging.FileFormats.Webp.WebPFrameBlock;
if (frameBlock != null)
{
System.Console.WriteLine("Frame={0}, FileFormat={1}, HasAlpha={2}", i++, frameBlock.RawDataFormat, frameBlock.HasAlpha);
}
}
}
// The output may look like this:
// ImageFile=c:\temp\sample.webp, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False
// Frame=0, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False
Options
恢复或修改与指定属性相关的选项,允许精心调整的定制行为和设置. 使用此属性无缝访问和操纵可配置的参数,方便多元化控制和优化在您的应用程序功能范围内。
[JsonProperty]
public WebPOptions Options { get; }
财产价值
PageCount
恢复所指定的文件中的页面总数,方便有效的导航和管理多页内容。功能性,以提高用户体验,允许无缝访问全面的文件结构。
public override int PageCount { get; }
财产价值
Pages
在图像中访问 WebP 区块,允许详细审查或对底部区块结构的操纵 使用此属性来分析或在 WebP 图像数据中修改个别区块,使先进的图像处理技术在您的应用中。
public override Image[] Pages { get; }
财产价值
Image ( )
Methods
AddBlock(伊弗拉姆)
将一个新的 WebP 区块纳入图像中,丰富其内容和促进先进的图像操纵. 将此方法集成到动态提高 WebP 图像数据的结构和复杂性应用,可准确控制和优化图像 rendering。
public void AddBlock(IFrame block)
Parameters
block
IFrame
Webp 阻止添加。
Examples
此示例显示如何使用指定的选项创建多框动画 WebP 图像。
string dir = "c:\\temp\\";
Aspose.Imaging.ImageOptions.WebPOptions createOptions = new Aspose.Imaging.ImageOptions.WebPOptions();
createOptions.Lossless = true;
createOptions.Quality = 100f;
createOptions.AnimBackgroundColor = (uint)Aspose.Imaging.Color.Gray.ToArgb();
// The default frame plus 36 + 36 additional frames.
createOptions.AnimLoopCount = 36 + 36 + 1;
// Create a WebP image of 100x100 px.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
{
// The first circle is red
Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
// The second circle is black
Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);
// Gradually inscrease the angle of the red arc shape.
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
graphics.FillPie(brush1, block.Bounds, 0, angle);
webPImage.AddBlock(block);
}
// Gradually inscrease the angle of the black arc and wipe out the red arc.
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
graphics.FillPie(brush2, block.Bounds, 0, angle);
graphics.FillPie(brush1, block.Bounds, angle, 360 - angle);
webPImage.AddBlock(block);
}
// Save to a WebP file
webPImage.Save(dir + "output.webp");
}
AddPage(RasterImage)
将新页面添加到图像中,扩展其内容并容纳额外的内容视觉元素:将此方法集成,以便促进动态页面管理在您的应用程序中,允许无缝创建和扩展多页文件或图像。
public void AddPage(RasterImage page)
Parameters
page
RasterImage
添加的页面。
Exceptions
page’ is null.
AdjustBrightness(因特)
对图像进行 brightness’ 调整,允许对整体亮度水平进行 themodification. 将此方法纳入图像处理工作流中,以提高图像的可见性,提高图像的视觉质量。
public override void AdjustBrightness(int brightness)
Parameters
brightness
int
光的价值。
AdjustContrast(航海)
增強 Aspose.Imaging.Image 的對比,增強光和黑暗区域之间的差异 将此方法集成到您的图像中处理工作流以提高视觉清晰度和整体图像质量你的申请。
public override void AdjustContrast(float contrast)
Parameters
contrast
float
对比值(在范围内(100;100)
AdjustGamma(航海)
应用 Gamma 纠正到图像,调整像素强度到实现想要的亮度和颜色平衡. 将此方法纳入您的图像处理工作流,以提高视觉质量,提高精度在您的申请中进行后续分析或显示任务。
public override void AdjustGamma(float gamma)
Parameters
gamma
float
红色、绿色和蓝色频道的Gamma
AdjustGamma(航海、航海、航海)
在图像上进行伽马纠正,使用红色的个别坐标,绿色和蓝色频道,允许精细调整颜色平衡和将此方法集成到您的图像处理管道中,以实现精确控制颜色呈现,并在您的内部提高视觉忠诚度应用。
public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Parameters
gammaRed
float
红频率的Gamma
gammaGreen
float
绿色频道的Gamma
gammaBlue
float
蓝色频道的Gamma
BinarizeBradley(双重, int)
将二进制应用到图像中,使用布拉德利的适应边界算法以完整的图像边界计算,这种方法动态地计算基于图像附近的边界,提高适应性照明条件,并为后续处理提供坚固的分区您申请中的任务。
public override void BinarizeBradley(double brightnessDifference, int windowSize)
Parameters
brightnessDifference
double
像素之间的亮度差异和像素的平均窗口 s x s 的差异聚集在这个像素周围。
windowSize
int
这个像素周围集中的像素的 x s 窗口的尺寸
BinarizeFixed(比特)
在图像上进行二进制,使用预先定义的边界值,转换它进入一个二进制图像,在那里像素被分为前方或背景基于其与边界相对的强度,将此方法集成到您的图像处理工作流,以便促进分区和功能提取任务,提高后续分析的准确性和效率在您的内部应用。
public override void BinarizeFixed(byte threshold)
Parameters
threshold
byte
如果一个像素的相应灰色值超过边界值,则255 将被分配给它, 0 否则。
BinarizeOtsu()
在图像上进行二进制,使用Otsu的边缘化方法,自动确定基于图像的历史图的最佳边界值。将此方法插入您的图像处理工作流,以实现有效的分区功能提取,提高图像分析的准确性和可靠性您申请中的任务。
public override void BinarizeOtsu()
ClearBlocks()
从图像中清除所有现有 WebP 区块,方便清洁随后的修改或添加. 使用此方法有效重新设置在 WebP 图像数据中的区块结构,确保最佳管理和在您的应用程序中组织图像内容。
public void ClearBlocks()
Crop(Rectangle)
使用指定的直角区域种植图像,删除不需要的部分同时保持所需内容. 将此方法集成到您的图像中处理工作流,精确提取和专注于特定兴趣领域在图像中,提高各种应用的清晰度和组成。
public override void Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
直角。
Crop(int , int , int , int , int)
通过应用左、右、上和底的转移,有效地种植图像。在图像中选择一个兴趣区域. 使用此方法动态地提取图像的所需部分,同时调整其组成并根据您的申请要求专注。
public override void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
int
左转。
rightShift
int
正确的转换。
topShift
int
顶级转换。
bottomShift
int
底部交换。
Dither(DitheringMethod, int,IColorPalette)
在当前图像上进行直播,以减少颜色连接,并提高视觉质量. 将此方法集成到您的图像处理工作流中,以实现更柔和的颜色之间的过渡,改善整体外观图像在您的应用中。
public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)
Parameters
ditheringMethod
DitheringMethod
定位方法。
bitsCount
int
最后的比特数为Ditering。
customPalette
IColorPalette
可用于Ditering的配件。
Filter(Rectangle, FilterOptions 基于)
在指定的直角内过滤内容,应用指定的图像处理过滤器以增强或修改所选择的区域。在您的图像操作工作流,以实现目标改进或在您的应用中进行转型。
public override void Filter(Rectangle rectangle, FilterOptionsBase options)
Parameters
rectangle
Rectangle
直角。
options
FilterOptionsBase
选项的。
Examples
下面的例子适用于WEB 图像的各种类型的过滤器。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
{
Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (Aspose.Imaging.FileFormats.Webp.WebPImage)image;
// Apply a median filter with a rectangle size of 5 to the entire image.
webpImage.Filter(webpImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MedianFilterOptions(5));
webpImage.Save(dir + "sample.MedianFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
{
Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (Aspose.Imaging.FileFormats.Webp.WebPImage)image;
// Apply a bilateral smoothing filter with a kernel size of 5 to the entire image.
webpImage.Filter(webpImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.BilateralSmoothingFilterOptions(5));
webpImage.Save(dir + "sample.BilateralSmoothingFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
{
Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (Aspose.Imaging.FileFormats.Webp.WebPImage)image;
// Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire image.
webpImage.Filter(webpImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 4.0));
webpImage.Save(dir + "sample.GaussianBlurFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
{
Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (Aspose.Imaging.FileFormats.Webp.WebPImage)image;
// Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire image.
webpImage.Filter(webpImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussWienerFilterOptions(5, 4.0));
webpImage.Save(dir + "sample.GaussWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
{
Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (Aspose.Imaging.FileFormats.Webp.WebPImage)image;
// Apply a motion wiener filter with a length of 5, a smooth value of 4.0 and an angle of 90.0 degrees to the entire image.
webpImage.Filter(webpImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MotionWienerFilterOptions(10, 1.0, 90.0));
webpImage.Save(dir + "sample.MotionWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
{
Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (Aspose.Imaging.FileFormats.Webp.WebPImage)image;
// Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire image.
webpImage.Filter(webpImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.SharpenFilterOptions(5, 4.0));
webpImage.Save(dir + "sample.SharpenFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Grayscale()
将图像转化为其灰层代表性,将其转化为一个单频道图像,每个像素代表强度或亮度。这个方法进入您的图像处理管道,以简化分析和改进与基于格里斯卡的算法兼容性,方便各种计算机视觉和图像分析任务在您的应用程序内。
public override void Grayscale()
InsertBlock(伊斯特,伊斯特)
在图像中将一个新的 WebP 区块插入指定的索引中,使其准确控制区块序列. 整合此方法以无缝整合额外的 WebP 区块进入图像数据结构,促进先进图像在您的应用程序中进行处理和优化。
public void InsertBlock(int index, IFrame block)
Parameters
index
int
以零为基础的元素,其中 block’ 将被插入。
block
IFrame
Webp 阻止添加。
ReleaseManagedResources()
释放管理的资源. 确保没有未管理的资源在这里释放,因为它们可能已经已经释放了
protected override void ReleaseManagedResources()
RemoveBlock(伊弗拉姆)
从图像中删除指定的 WebP 区块,方便有效管理图像数据结构 使用此方法以简化图像处理工作流通过在您的应用程序中消除不必要的区块或组件。
public void RemoveBlock(IFrame block)
Parameters
block
IFrame
要取消的区块。
Remarks
注意: 请不要忘记将 block’ 设置,如果您不希望将其添加到其他 WebPImage。
Resize(int , int , resizeType)
重新调整图像,调整其尺寸,同时保持视角比例。将此方法集成到您的图像处理工作流中以动态规模图像适合您的应用程序中的各种显示或存储要求。
public override void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
新的宽度。
newHeight
int
新高度。
resizeType
ResizeType
回归类型。
Examples
这个例子加载了一个WEBP图像,并使用各种重复方法重新编辑它。
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Webp.WebPImage image = (Aspose.Imaging.FileFormats.Webp.WebPImage)Aspose.Imaging.Image.Load(dir + "sample.webp"))
{
// Scale up by 2 times using Nearest Neighbour resampling.
image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with default options.
image.Save(dir + "upsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Webp.WebPImage image = (Aspose.Imaging.FileFormats.Webp.WebPImage)Aspose.Imaging.Image.Load(dir + "sample.webp"))
{
// Scale down by 2 times using Nearest Neighbour resampling.
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with default options.
image.Save(dir + "downsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Webp.WebPImage image = (Aspose.Imaging.FileFormats.Webp.WebPImage)Aspose.Imaging.Image.Load(dir + "sample.webp"))
{
// Scale up by 2 times using Bilinear resampling.
image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with default options.
image.Save(dir + "upsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Webp.WebPImage image = (Aspose.Imaging.FileFormats.Webp.WebPImage)Aspose.Imaging.Image.Load(dir + "sample.webp"))
{
// Scale down by 2 times using Bilinear resampling.
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with default options.
image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Resize(int , int , ImageResizeSettings)
根据规定的设置重定向图像,可准确控制尺寸,方面比例,和扩展行为. 将此方法集成到您的图像处理工作流,以实现自定义重复操作您申请的具体要求。
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
int
新的宽度。
newHeight
int
新高度。
settings
ImageResizeSettings
重新设置。
ResizeHeightProportionally(重定向,重定向)
比例调整图像的高度,同时保持其视角比例为一致的反射. 将此方法集成到您的图像处理工作流以均匀的比例动态复制图像,确保最佳显示或在您的应用中存储。
public override void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
Parameters
newHeight
int
新高度。
resizeType
ResizeType
回归的类型。
ResizeWidthProportionally(重定向,重定向)
相对调整图像的宽度,同时保持其视角比例。将此方法集成到您的图像处理工作流中,以动态复制具有一致的比例的图像,确保最佳显示或内存你的申请。
public override void ResizeWidthProportionally(int newWidth, ResizeType resizeType)
Parameters
newWidth
int
新的宽度。
resizeType
ResizeType
回归的类型。
Rotate(彩色 , 彩色 , 彩色)
旋转图像在其中心周围的指定角度,而比例重复它并应用指定的背景颜色参数。方法进入您的图像处理工作流,以实现准确的转型可自定义背景颜色,确保您内部的最佳视觉呈现应用。
public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
Parameters
angle
float
旋转的角度在度,积极的值会旋转时钟。
resizeProportionally
bool
如果设置为“真实”,您的图像大小将根据旋转直角(角点)的图像在其他情况下,留下尺寸无触摸,只有内部图像内容被旋转。
backgroundColor
Color
背景的颜色。
RotateFlip(RotateFlipType)
应用旋转、滑动或两种操作,仅适用于活跃框架。将此方法集成到您的图像处理工作流中确保个人框架的准确操作,提高灵活性和在您的应用程序中控制框架转换。
public override void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipType
旋转的Flip类型。
SaveData(Stream)
保存数据。
protected override void SaveData(Stream stream)
Parameters
stream
Stream
流来保存数据。
UpdateDimensions(int , int , int)
更新图像尺寸。
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
新图像宽度。
newHeight
int
新图像高度。