Class ApngOptions

Class ApngOptions

ชื่อพื้นที่: Aspose.Imaging.ImageOptions การประกอบ: Aspose.Imaging.dll (25.4.0)

API สําหรับรูปแบบไฟล์ภาพ PNG (Graphics of Animated Portable Network)การสร้างเป็นเครื่องมือแบบไดนามิกสําหรับนักพัฒนาที่กําลังมองหาที่จะสร้างความตื่นเต้นภาพเคลื่อนไหว ด้วยตัวเลือกที่กําหนดเองเช่นระยะเวลาเฟรมและจํานวนครั้งในการล็อค 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 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; }

คุณสมบัติมูลค่า

uint

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นว่าวิธีการส่งออกรูปแบบไฟล์ APNG 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 แสดงให้เห็นถึงการ looping infinite

public int NumPlays { get; set; }

คุณสมบัติมูลค่า

int

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
                                                                         }
 แบบไทย