ApngOptions Class
The animated PNG file format options
Inheritance Hierarchy
SystemObject
  Aspose.ImagingDisposableObject
    Aspose.ImagingImageOptionsBase
      Aspose.Imaging.ImageOptionsPngOptions
        Aspose.Imaging.ImageOptionsApngOptions

Namespace: Aspose.Imaging.ImageOptions
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 21.04
Syntax
public class ApngOptions : PngOptions

The ApngOptions type exposes the following members.

Constructors
  NameDescription
Public methodApngOptions
Initializes a new instance of the ApngOptions class
Properties
  NameDescription
Public propertyCode exampleBitDepth
The bit depth.
(Inherited from PngOptions.)
Public propertyCode exampleBufferSizeHint
Gets or sets the buffer size hint which is defined max allowed size for all internal buffers.
(Inherited from ImageOptionsBase.)
Public propertyCode exampleColorType
Gets or sets the type of the color.
(Inherited from PngOptions.)
Public propertyCode exampleCompressionLevel
The png image compression level in the 0-9 range, where 9 is maximum compression and 0 is store mode.
(Inherited from PngOptions.)
Public propertyCode exampleDefaultFrameTime
Gets or sets the default frame duration.
Public propertyDisposed
Gets a value indicating whether this instance is disposed.
(Inherited from DisposableObject.)
Public propertyCode exampleFilterType
Gets or sets the filter type used during png file save process.
(Inherited from PngOptions.)
Public propertyFullFrame
Gets or sets a value indicating whether [full frame].
(Inherited from ImageOptionsBase.)
Public propertyMultiPageOptions
The multipage options
(Inherited from ImageOptionsBase.)
Public propertyCode exampleNumPlays
Gets or sets the number of times to loop animation. 0 indicates infinite looping.
Public propertyCode examplePalette
Gets or sets the color palette.
(Inherited from ImageOptionsBase.)
Public propertyCode exampleProgressEventHandler
Gets or sets the progress event handler.
(Inherited from ImageOptionsBase.)
Public propertyCode exampleProgressive
Gets or sets a value indicating whether this PngOptions is progressive.
(Inherited from PngOptions.)
Public propertyCode exampleResolutionSettings
Gets or sets the resolution settings.
(Inherited from ImageOptionsBase.)
Public propertySource
Gets or sets the source to create image in.
(Inherited from ImageOptionsBase.)
Public propertyVectorRasterizationOptions
Gets or sets the vector rasterization options.
(Inherited from ImageOptionsBase.)
Public propertyXmpData
Gets or sets the XMP metadata container.
(Inherited from PngOptions.)
Methods
  NameDescription
Public methodClone
Clones this instance.
(Inherited from ImageOptionsBase.)
Public methodCode exampleDispose
Disposes the current instance.
(Inherited from DisposableObject.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize (Inherited from DisposableObject.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodReleaseManagedResources
Releases the managed resources. Make sure no unmanaged resources are released here, since they may have been already released.
(Inherited from ImageOptionsBase.)
Protected methodReleaseUnmanagedResources
Releases the unmanaged resources. Make sure no managed resources are released here, since they may have been already released.
(Inherited from DisposableObject.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Protected methodVerifyNotDisposed
Verifies that the current instance is not disposed.
(Inherited from DisposableObject.)
Fields
  NameDescription
Protected fieldxmpData
XMP metadata of image.
(Inherited from ImageOptionsBase.)
Examples
The following example shows how to export apng APNG file format from other non-animated multi-page format.
[C#]

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
}
Examples
The following example shows how to export to APNG file format.
[C#]

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
}
Examples
The following example shows how to create APNG image from another raster single-page image.
[C#]

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();
    }
}
See Also