Class GifImage
名称: Aspose.Imaging.FileFormats.Gif 收藏: Aspose.Imaging.dll (25.4.0)
图形交换格式(GIF)图像文件的API提供开发者具有多元化的工具来处理压缩的拉斯特图像和动画 GIF. 提供功能,如 XMP 数据处理,颜色板设置,背景和透明的颜色控制,不透明度设置,重新测量,种植,过滤应用,伽马纠正,对比调整,灰层转换和转换到其他格式. 此 API 可无缝对各种应用程序进行操作和改进GIF图像。
[JsonObject(MemberSerialization.OptIn)]
public sealed class GifImage : RasterCachedMultipageImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImageExt, IMultipageImage
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← RasterImage ← RasterCachedImage ← RasterCachedMultipageImage ← GifImage
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
从基于时间间隔的GIF图像中导出动画的一部分。
using (var image = Image.Load("Animation.gif"))
{
var options = new GifOptions
{
FullFrame = true,
MultiPageOptions = new MultiPageOptions
{
Mode = MultiPageMode.TimeInterval,
TimeInterval = new TimeInterval(0, 400)
}
};
image.Save("PartOfAnimation.gif", options);
}
此示例显示如何创建 GIF 图像并将其保存到文件中。
string dir = "c:\\temp\\";
// Create a GIF Frame block of 100x100 px.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
// Fill the entire block in red.
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
gr.FillRectangle(brush, firstBlock.Bounds);
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
gifImage.Save(dir + "output.gif");
}
}
使用单页拉斯特图像创建多页GIF图像。
static void Main(string[] args)
{
// Load frames
var frames = LoadFrames("Animation frames").ToArray();
// Create GIF image using the first frame
using (var image = new GifImage(new GifFrameBlock(frames[0])))
{
// Add frames to the GIF image using the AddPage method
for (var index = 1; index < frames.Length; index++)
{
image.AddPage(frames[index]);
}
// Save GIF image
image.Save("Multipage.gif");
}
}
private static IEnumerable<rasterimage> LoadFrames(string directory)
{
foreach (var filePath in Directory.GetFiles(directory))
{
yield return (RasterImage)Image.Load(filePath);
}
}</rasterimage>
Constructors
GifImage(GifFrameBlock 和 IColorPalette)
启动一个新的 Aspose.Imaging.FileFormats.Gif.GifImage 对象,并为第一框和全球范围. 开始快速管理 GIF 图像,确保精确的代表性,可自定义设置,以获得最佳结果。
public GifImage(GifFrameBlock firstFrame, IColorPalette globalPalette)
Parameters
firstFrame
GifFrameBlock
第一個框架以開始GIF圖像。
globalPalette
IColorPalette
请注意,如果 firstFrame’ 和
globalPalette’ 都是零的,则默认的全球板是使用的。
Examples
此示例显示如何使用自定义板创建 GIF 图像并将其保存到文件中。
string dir = "c:\\temp\\";
// Create a GIF Frame block of 100x100 px.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
// Fill the entire block in red.
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
gr.FillRectangle(brush, firstBlock.Bounds);
// Use 4-bit palette to reduce the image size. The quality can get worse.
Aspose.Imaging.IColorPalette palette = Aspose.Imaging.ColorPaletteHelper.Create4Bit();
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock, palette))
{
gifImage.Save(dir + "output.gif");
}
}
Exceptions
firstFrame’ 不可能是零
firstFrame’ 已经属于其他图像。
globalPalette’ 所指的应包含输入数等于 2 的功率。
GifImage(GifFrameBlock)
使用 Aspose.Imaging.FileFormats.Gif.GifImage 创建 GIF 图像变得无力只有第一Frame 参数,它进入了动态世界。视觉沟通。
public GifImage(GifFrameBlock firstFrame)
Parameters
firstFrame
GifFrameBlock
第一個框架以開始GIF圖像。
Examples
此示例显示如何创建 GIF 图像并将其保存到文件中。
string dir = "c:\\temp\\";
// Create a GIF Frame block of 100x100 px.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
// Fill the entire block in red.
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
gr.FillRectangle(brush, firstBlock.Bounds);
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
gifImage.Save(dir + "output.gif");
}
}
下面的例子显示如何从个别的GIF区块组成动画GIF图像。
string dir = "c:\\temp\\";
// Create a GIF image 100 x 100 px.
// The first block is fully black by default.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
// 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.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush1, block.Bounds, 0, angle);
gifImage.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.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush2, block.Bounds, 0, angle);
gr.FillPie(brush1, block.Bounds, angle, 360 - angle);
gifImage.AddBlock(block);
}
gifImage.Save(dir + "animated_radar.gif");
}
Exceptions
firstFrame’ 不可能是零
firstFrame’ 已经属于其他图像。
所指定的板块必须包含输入数等于功率2的最低板块大小为2、最大板块为256。
GifImage(GifFrameBlock, IColorPalette, bool, byte, byte, byte, bool)
從 Aspose.Imaging.FileFormats.Gif.GifImage 構造器開始。简单的方法,你可以轻松地沉浸在创建动画GIF。firstFrame, globalPalette, paletteColorResolution, aspectRatio,等参数,你准备好把你的视觉带到生命中。
public GifImage(GifFrameBlock firstFrame, IColorPalette globalPalette, bool isPaletteSorted, byte paletteColorResolution, byte paletteBackgroundColorIndex, byte aspectRatio, bool hasTrailer)
Parameters
firstFrame
GifFrameBlock
第一個框架以開始GIF圖像。
globalPalette
IColorPalette
请注意,如果 firstFrame’ 和
globalPalette’ 都是零的,则默认的全球板是使用的。
isPaletteSorted
bool
如果设置为“真实”,则分类为“真实”。 请注意,当 globalPalette" 不为 null 时,则使用参数。
paletteColorResolution
byte
彩色分辨率 请注意,当 globalPalette’ 没有 null 时使用的参数。
paletteBackgroundColorIndex
byte
背景色彩指数。
aspectRatio
byte
方面比例。
hasTrailer
bool
如果设置为“真实”的GIF图像有拖拉机,否则没有拖拉机写在流的结尾。
Exceptions
firstFrame’ 不可能是零
firstFrame’ 已经属于其他图像。
globalPalette’ 所指的应包含输入数等于 2 的功率。
Properties
ActiveFrame
管理和操纵这个属性的框架,允许顺利的导航和在 GIF 图像中更改活跃框架。
public GifFrameBlock ActiveFrame { get; set; }
财产价值
Examples
下面的例子显示如何从GIF图像中删除所有区块。
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
if (gifImage.ActiveFrame != null)
{
System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
}
else
{
System.Console.WriteLine("Active frame is not set");
}
System.Console.WriteLine("Clear all the blocks");
gifImage.ClearBlocks();
if (gifImage.ActiveFrame != null)
{
System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
}
else
{
System.Console.WriteLine("Active frame is not set");
}
}
// The output looks like this:
// Active frame size: { Width = 100, Height = 100}
// Clear all the blocks
// Active frame is not set
BackgroundColor
使用此属性管理 GIF 图像的背景颜色. 您可以设置或恢复背景颜色,以确保一致性和增强视觉吸引力。
public override Color BackgroundColor { get; set; }
财产价值
BackgroundColorIndex
使用此属性控制 GIF 图像的背景颜色指数。接收指数以保持一致性或实现所需的视觉效果。
public byte BackgroundColorIndex { get; set; }
财产价值
Blocks
获得与此属性无缝访问GIF区块,方便方便获取和操纵图像的基本数据结构。
public IGifBlock[] Blocks { get; }
财产价值
IGifBlock ( )
FileFormat
用此属性轻松恢复文件格式。要识别您的文件格式. 无缝集成到您的工作流,它提供不可或缺的信息,没有任何混乱。
public override FileFormat FileFormat { get; }
财产价值
HasBackgroundColor
此属性决定GIF图像是否包含背景颜色。事实上,它表明图像包含背景颜色。
public override bool HasBackgroundColor { get; }
财产价值
HasTrailer
管理在您的 GIF 文件中的拖拉机的存在,使用此属性。需要检查是否有拖拉机或设置其存在,此属性简化了保持您的 GIF 文件结构化和符合此直观功能。
public bool HasTrailer { get; set; }
财产价值
HasTransparentColor
确定GIF图像的活跃框是否包含透明的颜色。此属性提供了一个方便的方式来检查图像内部的透明度。
public override bool HasTransparentColor { get; set; }
财产价值
ImageOpacity
恢复在图像中活跃框的可见性,提供洞察力其透明度水平. 此属性特别有用于了解图像中的活性框架的透明度或不透明度。
public override float ImageOpacity { get; }
财产价值
IsInterlaced
确定图像是否相互关联,在加载时影响其显示。财产提供对图像的表现行为的洞察力,不可或缺优化负载策略,并提高整体观看体验。
public bool IsInterlaced { get; }
财产价值
IsPaletteSorted
控制您的 GIF 图像中的分类,使用此属性。你需要检查是否分类板或设置分类行为,这财产提供一个简单的方式来管理您的组织的板块GIF 文件
public bool IsPaletteSorted { get; set; }
财产价值
LoopsCount
用此属性轻松恢复旋转计算,如果您的 GIF 图像包含路径信息,此属性为您提供快速访问路径计算,允许您可以轻松地管理您的 GIF 文件中的旋转行为。
public int LoopsCount { get; set; }
财产价值
PageCount
恢复图像中包含的页面总数简单的属性. 理想的快速评估图像内容的范围。
public override int PageCount { get; }
财产价值
Pages
通过此方便的属性获得图像内的页面访问,允许无缝导航和按需要对单个页面进行操作。
public override Image[] Pages { get; }
财产价值
Image ( )
PaletteColorResolutionBits
使用此属性管理您的 GIF 图像的彩色分辨率。用于代表色彩的比特数量,提供精致的控制颜色深度和图像质量。
public byte PaletteColorResolutionBits { get; set; }
财产价值
PixelAspectRatio
与此属性管理 GIF 图像的像素视角比例 设置或获取方面比例,以确保准确的表现,并保持视觉忠诚。
public byte PixelAspectRatio { get; set; }
财产价值
TransparentColor
在 GIF 图像中恢复活跃框的透明颜色。允许您访问已被指定为透明的特定颜色在目前的活跃框架内。
public override Color TransparentColor { get; }
财产价值
XmpData
使用此属性管理 XMP 金属数据 您是否正在获取现有金属数据或更新它与新的信息,这个属性简化过程。您的数据是有组织和可访问的,确保您的文件包含他们需要的相关信息。
public override XmpPacketWrapper XmpData { get; set; }
财产价值
Methods
AddBlock(伊格布洛克)
添加一个新的 GIF 区块允许您在图像中包含额外的数据。此方法允许您将自定义区块添加到 GIF 图像中,可包含各种类型的信息。
public void AddBlock(IGifBlock block)
Parameters
block
IGifBlock
GIF 区块添加。
Examples
下面的例子显示如何从个别的GIF区块组成动画GIF图像。
string dir = "c:\\temp\\";
// Create a GIF image 100 x 100 px.
// The first block is fully black by default.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
// 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.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush1, block.Bounds, 0, angle);
gifImage.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.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush2, block.Bounds, 0, angle);
gr.FillPie(brush1, block.Bounds, angle, 360 - angle);
gifImage.AddBlock(block);
}
gifImage.Save(dir + "animated_radar.gif");
}
AddPage(RasterImage)
将新页面无缝嵌入到现有图像中,增强其内容并扩展其范围. 这种方法增加图像收藏的额外内容,促进图像管理和组成中的创造力和灵活性。
public void AddPage(RasterImage page)
Parameters
page
RasterImage
添加的页面。
Examples
使用单页拉斯特图像创建多页GIF图像。
static void Main(string[] args)
{
// Load frames
var frames = LoadFrames("Animation frames").ToArray();
// Create GIF image using the first frame
using (var image = new GifImage(new GifFrameBlock(frames[0])))
{
// Add frames to the GIF image using the AddPage method
for (var index = 1; index < frames.Length; index++)
{
image.AddPage(frames[index]);
}
// Save GIF image
image.Save("Multipage.gif");
}
}
private static IEnumerable<rasterimage> LoadFrames(string directory)
{
foreach (var filePath in Directory.GetFiles(directory))
{
yield return (RasterImage)Image.Load(filePath);
}
}</rasterimage>
Exceptions
page’ is null.
AdjustBrightness(因特)
根据指定的亮度参数调整图像的亮度,这种方法均匀地调整整个图像的亮度,提高或减少整体亮度,以实现所需效果。
public override void AdjustBrightness(int brightness)
Parameters
brightness
int
光的价值。
Examples
下面的例子执行GIF图像的亮度纠正。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Set the brightness value. The accepted values of brightness are in the range [-255, 255].
gifImage.AdjustBrightness(50);
gifImage.Save(dir + "sample.AdjustBrightness.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustContrast(航海)
调整图像的对比,增强或减少图像的差异像素之间的亮度. 这种方法改变图像的整体色调范围,使更黑暗的区域更黑暗,更光明的区域更亮,以提高视觉清晰度和细节。
public override void AdjustContrast(float contrast)
Parameters
contrast
float
对比值(在范围内(100;100)
Examples
下面的例子进行GIF图像的对比纠正。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Set the contrast value. The accepted values of contrast are in the range [-100f, 100f].
gifImage.AdjustContrast(50f);
gifImage.Save(dir + "sample.AdjustContrast.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Exceptions
不能改变对比. 框架指数:“+框架指数
AdjustGamma(航海)
通过应用 Gamma 纠正来提高图像质量. 这种方法调整颜色图像的伽马以实现最佳视觉清晰度 它改变了伽马值每个像素,从而提高颜色表现和整体图像外观。
public override void AdjustGamma(float gamma)
Parameters
gamma
float
红色、绿色和蓝色频道的Gamma
Examples
下面的例子是GAMMA图像的GAMMA修复。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Set gamma coefficient for red, green and blue channels.
gifImage.AdjustGamma(2.5f);
gifImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustGamma(航海、航海、航海)
图像的 Gamma 纠正适用于非线性调整像素值,增强或减少基于红色指定的比率的亮度;绿色,和蓝色频道. 这种方法有助于清洁颜色平衡和图像的亮度,改善其整体外观和视觉质量。
public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Parameters
gammaRed
float
红频率的Gamma
gammaGreen
float
绿色频道的Gamma
gammaBlue
float
蓝色频道的Gamma
Examples
下面的例子对GIF图像进行伽马修复,应用不同颜色组件的比例。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Set individual gamma coefficients for red, green and blue channels.
gifImage.AdjustGamma(1.5f, 2.5f, 3.5f);
gifImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeBradley(双重)
使用布拉德利的适应边界算法进行图像的二进制化整合图像边界是将图像转换为一个图像。二进制图像 这个算法计算每个像素的本地边界,基于指定的窗口内的周围像素的平均强度。适应性调整基于本地像素强度的边界,布拉德利该方法有效处理照明和对比的变化在图像上。
public override void BinarizeBradley(double brightnessDifference)
Parameters
brightnessDifference
double
像素之间的亮度差异和一个 s x s 窗口的像素在这个像素周围的平均差异。
BinarizeFixed(比特)
图像的二元化与预先定义的边界转换为灰色或颜色图像进入二进制图像,每个像素分为黑色或白色。基于其强度值是否超过指定的限制。
public override void BinarizeFixed(byte threshold)
Parameters
threshold
byte
如果一个像素的相应灰色值超过边界,则将分配给它255的值,否则将分配给它0。
Examples
下面的例子将GIF图像与预先定义的边界二元化,二元化图像只包含2种颜色 - 黑色和白色。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage djvuImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Binarize the image with a threshold value of 127.
// If a corresponding gray value of a pixel is greater than 127, a value of 255 will be assigned to it, 0 otherwise.
djvuImage.BinarizeFixed(127);
djvuImage.Save(dir + "sample.BinarizeFixed.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeOtsu()
图像的二元化与 Otsu 边界化是一种自动使用的方法确定将图像转换为图像的最佳边界值二进制图像. Otsu 边界算法计算的边界尽量减少二分之一的像素强度的内分类变异。课程(前面和背景) 这种技术特别有用,当最佳边界值是未知的,必须以适应性为基础确定。图像中的希斯图。
public override void BinarizeOtsu()
Examples
下面的例子二元化了一个GIF图像与Otsu边界。二元化图像只包含2种颜色 - 黑色和白色。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Binarize the image with Otsu thresholding.
gifImage.BinarizeOtsu();
gifImage.Save(dir + "sample.BinarizeOtsu.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ClearBlocks()
清除所有 GIF 区块将删除图像中存储的任何现有数据。此操作有效地将图像恢复到空状态,删除任何以前添加的区块. 使用这种方法,当你需要开始新鲜的清洁点击创建或修改 GIF 图像。
public void ClearBlocks()
Examples
下面的例子显示如何从GIF图像中删除所有区块。
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
if (gifImage.ActiveFrame != null)
{
System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
}
else
{
System.Console.WriteLine("Active frame is not set");
}
System.Console.WriteLine("Clear all the blocks");
gifImage.ClearBlocks();
if (gifImage.ActiveFrame != null)
{
System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
}
else
{
System.Console.WriteLine("Active frame is not set");
}
}
// The output looks like this:
// Active frame size: { Width = 100, Height = 100}
// Clear all the blocks
// Active frame is not set
Crop(Rectangle)
使用指定的直角区域种植图像,此操作移除外部图像的部分,只留下由直角定义的选择区域。
public override void Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
直角。
Examples
下面的例子将收获GIF图像,收获区域将通过Aspose.Imaging.Rectangle指定。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Crop the image. The cropping area is the rectangular central area of the image.
Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(gifImage.Width / 4, gifImage.Height / 4, gifImage.Width / 2, gifImage.Height / 2);
gifImage.Crop(area);
// Save the cropped image to PNG
gifImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Dither(DitheringMethod, int,IColorPalette)
适用于当前图像,此过程提高图像质量减少颜色连接和改善颜色过渡,导致更顺利看起来。
public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)
Parameters
ditheringMethod
DitheringMethod
定位方法。
bitsCount
int
最后的比特数为Ditering。
customPalette
IColorPalette
可用于Ditering的配件。
Examples
下面的例子加载了一个GIF图像,并使用不同的分布深度进行边界和流动分布。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Perform threshold dithering using 4-bit color palette which contains 16 colors.
// The more bits specified the higher quality and the bigger size of the output image.
// Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
gifImage.Dither(Aspose.Imaging.DitheringMethod.ThresholdDithering, 4, null);
gifImage.Save(dir + "sample.ThresholdDithering4.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Perform floyd dithering using 1-bit color palette which contains only 2 colors - black and white.
// The more bits specified the higher quality and the bigger size of the output image.
// Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
gifImage.Dither(Aspose.Imaging.DitheringMethod.FloydSteinbergDithering, 1, null);
gifImage.Save(dir + "sample.FloydSteinbergDithering1.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Filter(Rectangle, FilterOptions 基于)
将特定的过滤器应用到图像的指定区域,增强其视觉品质或改變其所需的外觀. 這種方法選擇性處理定义直角内的像素,允许进行针对性调整同时保留周围图像数据的完整性。
public override void Filter(Rectangle rectangle, FilterOptionsBase options)
Parameters
rectangle
Rectangle
直角。
options
FilterOptionsBase
选项的。
Examples
下面的例子适用于各种类型的过滤器的GIF图像。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Apply a median filter with a rectangle size of 5 to the entire image.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MedianFilterOptions(5));
gifImage.Save(dir + "sample.MedianFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Apply a bilateral smoothing filter with a kernel size of 5 to the entire image.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.BilateralSmoothingFilterOptions(5));
gifImage.Save(dir + "sample.BilateralSmoothingFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire image.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 4.0));
gifImage.Save(dir + "sample.GaussianBlurFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire image.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussWienerFilterOptions(5, 4.0));
gifImage.Save(dir + "sample.GaussWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)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.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MotionWienerFilterOptions(10, 1.0, 90.0));
gifImage.Save(dir + "sample.MotionWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire image.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.SharpenFilterOptions(5, 4.0));
gifImage.Save(dir + "sample.SharpenFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
GetOriginalOptions()
恢复基于原始文件设置的选项,保持忠诚至关重要和图像处理和操纵的一致性. 这种方法允许无缝将文件特定的参数集成到随后的操作中,确保精确的交付和遵守图像的本质特征。这可能有助于保持原始图像的细节深度和其他参数不变。例如,如果我们加载一张黑白的PNG图像,每像素1比特,然后使用Aspose.Imaging.DataStreamSupporter.Save(System.String)方法,输出PNG图像,每像素将产生8位。要避免它,并以每像素1比特保存PNG图像,使用此方法获得相应的储蓄选项并通过它们。在 Aspose.Imaging.Image.Save(System.String,Aspose.Imaging.ImageOptionsBase)方法作为第二个参数。
public override ImageOptionsBase GetOriginalOptions()
Returns
基于原始文件设置的选项。
Grayscale()
图像转化为其灰色图像转化为颜色图像在灰色版本,通过删除颜色信息同时保存这个过程简化图像到灰色的阴影,使其适合适用于各种应用,如印刷、文档处理和灰色尺寸分析。
public override void Grayscale()
Examples
下面的例子将彩色GIF图像转化为其灰色图像,灰色图像仅由灰色的阴影组成,仅提供强度信息。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Grayscale();
gifImage.Save(dir + "sample.Grayscale.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
InsertBlock(标签: IGIFBlock)
插入一个新的 GIF 区块允许您在特定位置添加自定义数据在图像中. 此方法允许您将自定义区块置于所需的位置GIF图像中的位置,提供组织和结构化的灵活性图像数据。
public void InsertBlock(int index, IGifBlock block)
Parameters
index
int
基于零的元素,在哪个区块将被插入。
block
IGifBlock
GIF 区块添加。
OnPaletteChanged(色彩,色彩,色彩)
被称为当板块变更时。
protected override void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
旧的板块。
newPalette
IColorPalette
新的板块。
OnPaletteChanging(色彩,色彩,色彩)
被称为当板块发生变化时。
protected override void OnPaletteChanging(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
旧的板块。
newPalette
IColorPalette
新的板块。
OrderBlocks()
按 GIF 规格订购 GIF 区块,确保适当的 GIF安排和遵守标准. 这个过程涉及安排按规格定义的正确序列区块。可能涉及移除某些 Aspose.Imaging.FileFormats.Gif.Blocks.GifGraphicsControlBlock 例子不需要最后的配置. 通过遵守 GIF 规格,结果图像将正确结构化并与 GIF 视图兼容申请。
public void OrderBlocks()
RemoveBlock(伊格布洛克)
删除 GIF 区块将从图像中删除特定数据,提供清理或修改图像结构. 此方法允许您删除不需要的或不必要的区块,优化GIF图像,以便有效存储。功能,以从图像中删除过时的信息,同时保存其完整性和质量。
public void RemoveBlock(IGifBlock block)
Parameters
block
IGifBlock
要取消的区块。
Remarks
注意:不要忘了将区块放置,如果您不会将其添加到其他 GifImage。
Resize(int , int , resizeType)
重定向这个 Aspose.Imaging.Image 例子。
public override void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
新的宽度。
newHeight
int
新高度。
resizeType
ResizeType
回归类型。
Examples
这个例子加载了一个GIF图像,并使用各种重复方法重新编辑它。
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
// Scale up by 2 times using Nearest Neighbour resampling.
image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "upsample.nearestneighbour.gif");
}
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
// Scale down by 2 times using Nearest Neighbour resampling.
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "downsample.nearestneighbour.gif");
}
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
// Scale up by 2 times using Bilinear resampling.
image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "upsample.bilinear.gif");
}
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
// Scale down by 2 times using Bilinear resampling.
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "downsample.bilinear.gif");
}
Resize(int , int , ImageResizeSettings)
重定向这个 Aspose.Imaging.Image 例子。
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
int
新的宽度。
newHeight
int
新高度。
settings
ImageResizeSettings
设置的。
Examples
此示例加载了 GIF 图像,并使用各种重新设置重新设置。
string dir = "c:\\temp\\";
Aspose.Imaging.ImageResizeSettings resizeSettings = new Aspose.Imaging.ImageResizeSettings();
// The adaptive algorithm based on weighted and blended rational function and lanczos3 interpolation.
resizeSettings.Mode = Aspose.Imaging.ResizeType.AdaptiveResample;
// The small rectangular filter
resizeSettings.FilterType = Aspose.Imaging.ImageFilterType.SmallRectangular;
// The number of colors in the palette.
resizeSettings.EntriesCount = 256;
// The color quantization is not used
resizeSettings.ColorQuantizationMethod = ColorQuantizationMethod.None;
// The euclidian method
resizeSettings.ColorCompareMethod = ColorCompareMethod.Euclidian;
using (Aspose.Imaging.Image image = (Aspose.Imaging.Image)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Scale down by 2 times using adaptive resampling.
gifImage.Resize(image.Width / 2, image.Height / 2, resizeSettings);
// Save to PNG
gifImage.Save(dir + "downsample.adaptive.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ResizeFullFrame(int , int , resizeType)
重定向图像,同时考虑到每个页面的完整框架GIF,从而防止潜在物品出现,这种方法是必不可少的保持图像的完整性和质量,特别是在处理图像时动画GIF或框序列。
public void ResizeFullFrame(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
新的宽度。
newHeight
int
新高度。
resizeType
ResizeType
回归类型。
ResizeProportional(int , int , resizeType)
相对重定向保持图像的视角比例,同时调整图像大小,确保图像看起来没有伸展或扭曲。 这种方法相对重定向图像,按相同因素规模宽度和高度。 相对重定向将根据 newWidth’/width 和
newHeight’/height 的比例重定向每个框。
public void ResizeProportional(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
新的宽度。
newHeight
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类型。
Examples
此示例加载 GIF 图像,以 90 度的时钟向旋转,并可选地垂直和(或)垂直滑动图像。
string dir = "c:\\temp\\";
Aspose.Imaging.RotateFlipType[] rotateFlipTypes = new Aspose.Imaging.RotateFlipType[]
{
Aspose.Imaging.RotateFlipType.Rotate90FlipNone,
Aspose.Imaging.RotateFlipType.Rotate90FlipX,
Aspose.Imaging.RotateFlipType.Rotate90FlipXY,
Aspose.Imaging.RotateFlipType.Rotate90FlipY,
};
foreach (Aspose.Imaging.RotateFlipType rotateFlipType in rotateFlipTypes)
{
// Rotate, flip and save to the output file.
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
image.RotateFlip(rotateFlipType);
image.Save(dir + "sample." + rotateFlipType + ".png", new Aspose.Imaging.ImageOptions.PngOptions());
}
}
SaveData(Stream)
保存数据。
protected override void SaveData(Stream stream)
Parameters
stream
Stream
流来保存数据。
SetFrameTime(威士忌)
调整每个框架的长度在毫秒,确保一致的时间整个图像序列. 此方法均匀设置显示时间每个框架,允许精确控制动画速度。更改此值将重新延迟所有框架。
public void SetFrameTime(ushort time)
Parameters
time
ushort
框架时间为千秒。
UpdateDimensions(int , int , int)
更新图像尺寸。
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
新图像宽度。
newHeight
int
新图像高度。