Class ApngImage
- Namespace
- Aspose.Imaging.FileFormats.Apng
- Assembly
- Aspose.Imaging.dll
The API for Animated PNG (Animated Portable Network Graphics) image file format is a versatile solution for developers looking to integrate animated content into their applications. This API offers extensive control over frame settings, allowing users to define frame-specific parameters, including loop duration and PNG file settings. With this feature-rich tool, you can effortlessly manage and optimize the display of APNG images, import and export images, enhancing the dynamic and interactive aspects of your applications.
public sealed class ApngImage : RasterCachedMultipageImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImageExt, IMultipageImage
- Inheritance
-
ApngImage
- Implements
- Inherited Members
Constructors
ApngImage(ApngOptions, int, int)
Begin working with the ApngImage class by initializing a new instance effortlessly. Perfect for developers seeking to start using ApngImage objects quickly and efficiently in their projects.
public ApngImage(ApngOptions options, int width, int height)
Parameters
options
ApngOptionsThe options.
width
intThe width.
height
intThe height.
Properties
DefaultFrameTime
Easily adjust the default frame duration for creating new frames with this flexible property. Perfect for developers seeking to customize frame timing efficiently in their animations.
public uint DefaultFrameTime { get; set; }
Property Value
- uint
The default frame duration, in milliseconds.
FileFormat
Quickly access information about the file format with this convenient property. Ideal for developers who need to retrieve details about the format of their Apng files easily.
public override FileFormat FileFormat { get; }
Property Value
Interlaced
Quickly determine whether this PngImage object is interlaced with this convenient property. Ideal for developers needing to check the interlacing status of PNG images easily.
public bool Interlaced { get; }
Property Value
- bool
true
if interlaced; otherwise,false
.
NumPlays
Effortlessly control the number of times your animation loops with this versatile property. Perfect for developers seeking precise control over animation behavior, with support for infinite looping in case of the value equals to 0.
public int NumPlays { get; set; }
Property Value
- int
The number of times to loop.
PageCount
Retrieve the total number of pages in your image file effortlessly with this property. Ideal for developers needing quick access to page count information.
public override int PageCount { get; }
Property Value
- int
The page count.
PageExportingAction
Effortlessly manage the page exporting action with this versatile property. Perfect for developers seeking precise control over the exporting behavior of pages in their application. Please note that setting this method will automatically release page resources after it is executed. It will be executed just before each page is saved.
public override PageExportingAction PageExportingAction { get; set; }
Property Value
- PageExportingAction
The page exporting action.
Pages
Effortlessly access the pages of your image with this convenient property. Perfect for developers seeking quick and easy access to individual pages for manipulation.
public override Image[] Pages { get; }
Property Value
- Image[]
The pages.
XmpData
Effortlessly manage XMP metadata associated with your files using this versatile property. Perfect for developers seeking to access or update metadata information with ease.
public override XmpPacketWrapper XmpData { get; set; }
Property Value
- XmpPacketWrapper
The XMP metadata.
Methods
AddFrame()
Easily append a new frame to the end of your frame collection with this straightforward method. Ideal for developers looking to expand their frame collection dynamically for animations with multi-frame images. A new frame will be created according to the size of the current image.
public ApngFrame AddFrame()
Returns
- ApngFrame
The newly created APNG frame.
AddFrame(RasterImage)
Effortlessly expand your frame collection by adding a new frame to the end with this intuitive method. Perfect for developers seeking to enhance their animations of multi-frame images dynamically. The contents of the new frame will be filled from the specified image.
public void AddFrame(RasterImage frameImage)
Parameters
frameImage
RasterImageThe frame image.
Exceptions
- ArgumentNullException
frameImage is null.
AddFrame(RasterImage, uint)
Expand your frame collection seamlessly by appending a new frame to the with this intuitive method. Ideal for developers looking to enrich their animations of multi-frame images. The contents of the new frame will be filled from the specified image.
public void AddFrame(RasterImage frameImage, uint frameTime)
Parameters
frameImage
RasterImageThe frame image.
frameTime
uintThe frame duration, in milliseconds.
Exceptions
- ArgumentNullException
frameImage is null.
AddPage(RasterImage)
Add a new page to the image effortlessly with this intuitive method. Perfect for developers seeking to expand the content of their image files dynamically.
public void AddPage(RasterImage page)
Parameters
page
RasterImageThe page to add.
Exceptions
- ArgumentNullException
page
is null.
AdjustBrightness(int)
Easily adjust the brightness
of the image with this intuitive method,
using the specified brightness parameter. Ideal for developers seeking to enhance or dim
the overall brightness of images dynamically.
public override void AdjustBrightness(int brightness)
Parameters
brightness
intBrightness value.
AdjustContrast(float)
Enhance the contrast of the Image to make details stand out with this intuitive method. Ideal for developers seeking to improve the visual clarity and impact of their images dynamically.
public override void AdjustContrast(float contrast)
Parameters
contrast
floatContrast value (in range [-100; 100])
AdjustGamma(float)
Apply gamma correction to the image using a floating-point coefficient with this intuitive method. Ideal for developers seeking precise color control in their images.
public override void AdjustGamma(float gamma)
Parameters
gamma
floatGamma for red, green and blue channels coefficient
AdjustGamma(float, float, float)
Perform gamma correction on the image separately for the red, green, and blue channels using individual coefficients with this intuitive method. Ideal for developers seeking to fine-tune color balance and enhance the visual quality of their images.
public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Parameters
gammaRed
floatGamma for red channel coefficient
gammaGreen
floatGamma for green channel coefficient
gammaBlue
floatGamma for blue channel coefficient
BinarizeBradley(double, int)
Binarization of an image using Bradley's adaptive thresholding algorithm using the integral image thresholding
public override void BinarizeBradley(double brightnessDifference, int windowSize)
Parameters
brightnessDifference
doubleThe brightness difference between pixel and the average of an s x s window of pixels centered around this pixel.
windowSize
intThe size of s x s window of pixels centered around this pixel
BinarizeFixed(byte)
Effortlessly binarize the image using a predefined threshold with this intuitive method. Ideal for developers seeking to convert images into binary form, simplifying them for further processing or analysis.
public override void BinarizeFixed(byte threshold)
Parameters
threshold
byteThreshold value. If corresponding gray value of a pixel is greater than threshold, a value of 255 will be assigned to it, 0 otherwise.
BinarizeOtsu()
Perform binarization on the image using Otsu thresholding with this intuitive method. Ideal for developers seeking to automatically determine the optimal threshold for converting images into binary form, enhancing their clarity and suitability for further analysis.
public override void BinarizeOtsu()
Crop(Rectangle)
Effortlessly crop the image to focus on specific areas with this intuitive method. Perfect for developers seeking to refine the composition of their images dynamically.
public override void Crop(Rectangle rectangle)
Parameters
rectangle
RectangleThe rectangle.
Crop(int, int, int, int)
Crop the image while adjusting shifts seamlessly with this intuitive method. Ideal for developers seeking precise control over the cropping process to focus on specific areas of their Apng images.
public override void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
intThe left shift.
rightShift
intThe right shift.
topShift
intThe top shift.
bottomShift
intThe bottom shift.
Dither(DitheringMethod, int, IColorPalette)
Easily apply dithering effects to the current image with this intuitive method. Ideal for developers looking to add texture or reduce color banding in their images.
public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)
Parameters
ditheringMethod
DitheringMethodThe dithering method.
bitsCount
intThe final bits count for dithering.
customPalette
IColorPaletteThe custom palette for dithering.
Filter(Rectangle, FilterOptionsBase)
Effortlessly apply filters to the specified rectangle of the image with this intuitive method. Perfect for developers seeking to enhance or modify specific areas.
public override void Filter(Rectangle rectangle, FilterOptionsBase options)
Parameters
rectangle
RectangleThe rectangle.
options
FilterOptionsBaseThe options.
GetDefaultOptions(object[])
Retrieve the default options effortlessly with this straightforward method. Ideal for developers seeking quick access to default Apng image settings.
public override ImageOptionsBase GetDefaultOptions(object[] args)
Parameters
args
object[]The arguments.
Returns
- ImageOptionsBase
Default options
GetModifyDate(bool)
Quickly obtain the date and time when the resource image was last modified with this user-friendly method. Ideal for developers needing to track changes and manage resources effectively.
public override DateTime GetModifyDate(bool useDefault)
Parameters
useDefault
boolif set to
true
uses the information from FileInfo as default value.
Returns
- DateTime
The date and time the resource image was last modified.
GetOriginalOptions()
Retrieve options based on the original file settings effortlessly with this intuitive method. Perfect for developers seeking to access and utilize settings that align with the characteristics of the original file. This can be helpful to keep bit-depth and other parameters of the original image unchanged. For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the Save(string) method, the output PNG image with 8-bit per pixel will be produced. To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them to the Save(string, ImageOptionsBase) method as the second parameter.
public override ImageOptionsBase GetOriginalOptions()
Returns
- ImageOptionsBase
The options based on the original file settings.
GetPagesAsEnumerable()
protected override IEnumerable<Image> GetPagesAsEnumerable()
Returns
Grayscale()
Easily transform the image into its grayscale representation with this intuitive method. Ideal for developers seeking to convert color images to grayscale, simplifying their visualization or analysis processes.
public override void Grayscale()
InsertFrame(int)
Effortlessly insert a new frame into your frame collection at the specified with this intuitive method. Ideal for developers seeking precise control over the arrangement of frames in their animations of multi-frame images. A new frame will be created according to the size of the current image.
public ApngFrame InsertFrame(int index)
Parameters
index
intThe index.
Returns
- ApngFrame
The newly created APNG frame.
Exceptions
- ArgumentOutOfRangeException
index
is less than 0. orindex
is greater than PageCount.
InsertFrame(int, RasterImage)
Inserts new frame into the own frame collection at the specified index. The contents of the new frame will be filled from the specified image.
public void InsertFrame(int index, RasterImage frameImage)
Parameters
index
intThe index.
frameImage
RasterImageThe frame image.
Exceptions
- ArgumentOutOfRangeException
index
is less than 0. orindex
is greater than PageCount.- ArgumentNullException
frameImage is null.
InsertFrame(int, RasterImage, uint)
Inserts new frame into the own frame collection at the specified index. The contents of the new frame will be filled from the specified image.
public void InsertFrame(int index, RasterImage frameImage, uint frameTime)
Parameters
index
intThe index.
frameImage
RasterImageThe frame image.
frameTime
uintThe frame duration, in milliseconds.
Exceptions
- ArgumentOutOfRangeException
index
is less than 0. orindex
is greater than PageCount.- ArgumentNullException
frameImage is null.
PopFrameAt(int)
Remove and retrieve the frame at the specified index from your frame collection with this intuitive method. Perfect for developers seeking efficient management of frames in their animations.
public ApngFrame PopFrameAt(int index)
Parameters
index
intThe index.
Returns
- ApngFrame
The removed APNG frame.
Exceptions
- ArgumentOutOfRangeException
index
is less than 0. orindex
is equal to or greater than PageCount.
ReleaseManagedResources()
protected override void ReleaseManagedResources()
RemoveAllFrames()
Clear your frame collection by removing all frames with this intuitive method. Ideal for developers seeking to reset or refresh their animations.
public void RemoveAllFrames()
RemoveFrameAt(int)
Remove the frame at the specified index from your frame collection seamlessly with this method. Perfect for developers seeking streamlined management of frames in their multi-frame images. The frame to be deleted will be disposed.
public void RemoveFrameAt(int index)
Parameters
index
intThe index.
Exceptions
- ArgumentOutOfRangeException
index
is less than 0. orindex
is equal to or greater than PageCount.
ResetDefaultImage()
Remove a previously set default image with this intuitive method. Ideal for developers seeking to reset or clear the default image in their animation. After this, the default image is the first frame in the own frame collection (it cannot be deleted using this method).
public void ResetDefaultImage()
Resize(int, int, ImageResizeSettings)
Resizes the image.
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
intThe new width.
newHeight
intThe new height.
settings
ImageResizeSettingsThe resize settings.
Resize(int, int, ResizeType)
Resize the image seamlessly with this intuitive method. Perfect for developers seeking to adjust the dimensions of their images dynamically.
public override void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
intThe new width.
newHeight
intThe new height.
resizeType
ResizeTypeThe resize type.
ResizeHeightProportionally(int, ResizeType)
Effortlessly adjust the height of your image while maintaining its proportions with this intuitive method. Perfect for developers looking to resize images dynamically while preserving their aspect ratio.
public override void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
Parameters
newHeight
intThe new height.
resizeType
ResizeTypeType of the resize.
ResizeWidthProportionally(int, ResizeType)
Proportionally resize the width of the image effortlessly with this intuitive method. Ideal for developers seeking to maintain the aspect ratio of their images while adjusting their dimensions.
public override void ResizeWidthProportionally(int newWidth, ResizeType resizeType)
Parameters
newWidth
intThe new width.
resizeType
ResizeTypeType of the resize.
Rotate(float, bool, Color)
Rotate the image around its center effortlessly with this intuitive method. Perfect for developers seeking to adjust the orientation of their images dynamically.
public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
Parameters
angle
floatThe rotate angle in degrees. Positive values will rotate clockwise.
resizeProportionally
boolif set to
true
you will have your image size changed according to rotated rectangle (corner points) projections in other case that leaves dimensions untouched and only internal image contents are rotated.backgroundColor
ColorColor of the background.
RotateFlip(RotateFlipType)
Effortlessly manipulate the active frame by rotating, flipping, or both with this intuitive method. Ideal for developers seeking to customize image frame orientations.
public override void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipTypeThe rotate flip type.
SaveData(Stream)
protected override void SaveData(Stream stream)
Parameters
stream
Stream
SetDefaultImage(RasterImage)
Set the specified raster image as the default image for the current animation effortlessly with this method. Perfect for developers seeking to customize the default image in their animations.
public void SetDefaultImage(RasterImage image)
Parameters
image
RasterImageThe image.
Exceptions
- ArgumentNullException
image is null.
UpdateDimensions(int, int)
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
UpdateMetadata()
Updates the image metadata.
protected override void UpdateMetadata()