Class ApngOptions
名称: Aspose.Imaging.ImageOptions 收藏: Aspose.Imaging.dll (25.4.0)
动画PNG(动画移动网络图形)图像文件格式的API创作是一个动态的工具,开发人员寻求产生吸引力动画图像. 有可自定义的选项,如框长度和旋转的时间数量,这个API允许精细调动的内容根据具体需求,无论是创建有兴趣的网页图形还是互动视觉,您可以使用此 API 无缝嵌入精确控制动画参数的APNG图像。
public class ApngOptions : PngOptions, IDisposable, IHasXmpData, IHasMetadata, ICloneable
Inheritance
object ← DisposableObject ← ImageOptionsBase ← PngOptions ← ApngOptions
Implements
IDisposable , IHasXmpData , IHasMetadata , ICloneable
继承人
PngOptions.DefaultCompressionLevel , PngOptions.ColorType , PngOptions.Progressive , PngOptions.FilterType , PngOptions.CompressionLevel , PngOptions.BitDepth , ImageOptionsBase.Clone() , ImageOptionsBase.ReleaseManagedResources() , ImageOptionsBase.KeepMetadata , ImageOptionsBase.XmpData , ImageOptionsBase.Source , ImageOptionsBase.Palette , ImageOptionsBase.ResolutionSettings , ImageOptionsBase.VectorRasterizationOptions , ImageOptionsBase.BufferSizeHint , ImageOptionsBase.MultiPageOptions , ImageOptionsBase.FullFrame , ImageOptionsBase.ProgressEventHandler , DisposableObject.Dispose() , DisposableObject.ReleaseManagedResources() , DisposableObject.ReleaseUnmanagedResources() , DisposableObject.VerifyNotDisposed() , DisposableObject.Disposed , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
下面的示例显示如何从其他非动画多页格式出口APNG文件格式。
using Aspose.Imaging;
using Aspose.Imaging.ImageOptions;
using (Image image = Image.Load("img4.tif")) {
// Setting up the default frame duration
image.Save("img4.tif.500ms.png", new ApngOptions() { DefaultFrameTime = 500 }); // 500 ms
image.Save("img4.tif.250ms.png", new ApngOptions() { DefaultFrameTime = 250 }); // 250 ms
}
下面的例子显示如何将其导出到APNG文件格式。
using Aspose.Imaging;
using Aspose.Imaging.ImageOptions;
using (Image image = Image.Load("Animation1.webp")) {
// Export to APNG animation with unlimited animation cycles as default
image.Save("Animation1.webp.png", new ApngOptions());
// Setting up animation cycles
image.Save("Animation2.webp.png", new ApngOptions() { NumPlays = 5 }); // 5 cycles
}
下面的示例显示如何从另一个单页图像中创建APNG图像。
using Aspose.Imaging;
using Aspose.Imaging.ImageOptions;
using Aspose.Imaging.FileFormats.Apng;
const int AnimationDuration = 1000; // 1 s
const int FrameDuration = 70; // 70 ms
using (RasterImage sourceImage = (RasterImage)Image.Load("not_animated.png"))
{
ApngOptions createOptions = new ApngOptions
{
Source = new FileCreateSource("raster_animation.png", false),
DefaultFrameTime = (uint)FrameDuration,
ColorType = PngColorType.TruecolorWithAlpha,
};
using (ApngImage apngImage = (ApngImage)Image.Create(
createOptions,
sourceImage.Width,
sourceImage.Height))
{
// It is possible to set image default frame time there: apngImage.DefaultFrameTime = (uint)FrameDuration;
int numOfFrames = AnimationDuration / FrameDuration;
int numOfFrames2 = numOfFrames / 2;
// Cleaning because the image contains one frame by default
apngImage.RemoveAllFrames();
// add first frame
apngImage.AddFrame(sourceImage);
// add intermediate frames
for (int frameIndex = 1; frameIndex < numOfFrames - 1; ++frameIndex)
{
apngImage.AddFrame(sourceImage);
ApngFrame lastFrame = (ApngFrame)apngImage.Pages[apngImage.PageCount - 1];
float gamma = frameIndex >= numOfFrames2 ? numOfFrames - frameIndex - 1 : frameIndex;
lastFrame.AdjustGamma(gamma);
}
// add last frame
apngImage.AddFrame(sourceImage);
apngImage.Save();
}
}
Constructors
ApngOptions()
启动 Aspose.Imaging.ImageOptions.ApngOptions 类的新例子。
public ApngOptions()
Properties
DefaultFrameTime
接收或设置默认框长度。
public uint DefaultFrameTime { get; set; }
财产价值
Examples
下面的示例显示如何从其他非动画多页格式出口APNG文件格式。
using Aspose.Imaging;
using Aspose.Imaging.ImageOptions;
using (Image image = Image.Load("img4.tif")) {
// Setting up the default frame duration
image.Save("img4.tif.500ms.png", new ApngOptions() { DefaultFrameTime = 500 }); // 500 ms
image.Save("img4.tif.250ms.png", new ApngOptions() { DefaultFrameTime = 250 }); // 250 ms
}
下面的示例显示如何从另一个单页图像中创建APNG图像。
using Aspose.Imaging;
using Aspose.Imaging.ImageOptions;
using Aspose.Imaging.FileFormats.Apng;
const int AnimationDuration = 1000; // 1 s
const int FrameDuration = 70; // 70 ms
using (RasterImage sourceImage = (RasterImage)Image.Load("not_animated.png"))
{
ApngOptions createOptions = new ApngOptions
{
Source = new FileCreateSource("raster_animation.png", false),
DefaultFrameTime = (uint)FrameDuration,
ColorType = PngColorType.TruecolorWithAlpha,
};
using (ApngImage apngImage = (ApngImage)Image.Create(
createOptions,
sourceImage.Width,
sourceImage.Height))
{
// It is possible to set image default frame time there: apngImage.DefaultFrameTime = (uint)FrameDuration;
int numOfFrames = AnimationDuration / FrameDuration;
int numOfFrames2 = numOfFrames / 2;
// Cleaning because the image contains one frame by default
apngImage.RemoveAllFrames();
// add first frame
apngImage.AddFrame(sourceImage);
// add intermediate frames
for (int frameIndex = 1; frameIndex < numOfFrames - 1; ++frameIndex)
{
apngImage.AddFrame(sourceImage);
ApngFrame lastFrame = (ApngFrame)apngImage.Pages[apngImage.PageCount - 1];
float gamma = frameIndex >= numOfFrames2 ? numOfFrames - frameIndex - 1 : frameIndex;
lastFrame.AdjustGamma(gamma);
}
// add last frame
apngImage.AddFrame(sourceImage);
apngImage.Save();
}
}
NumPlays
接收或设置旋转动画的次数。0 表示无限旋转。
public int NumPlays { get; set; }
财产价值
Examples
下面的例子显示如何将其导出到APNG文件格式。
using Aspose.Imaging;
using Aspose.Imaging.ImageOptions;
using (Image image = Image.Load("Animation1.webp")) {
// Export to APNG animation with unlimited animation cycles as default
image.Save("Animation1.webp.png", new ApngOptions());
// Setting up animation cycles
image.Save("Animation2.webp.png", new ApngOptions() { NumPlays = 5 }); // 5 cycles
}