public final class ApngImage extends RasterCachedMultipageImage implements IMultipageImageExt
The animated PNG image.
The following example shows how to export to APNG file format.
import com.aspose.imaging;
import com.aspose.imaging.imageoptions;
try (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
ApngOptions options = new ApngOptions();
options.setNumPlays(5);
image.save("Animation2.webp.png", options); // 5 cycles
}
| Constructor and Description |
|---|
ApngImage(ApngOptions options,
int width,
int height)
Initializes a new instance of the
ApngImage class. |
| Modifier and Type | Method and Description |
|---|---|
ApngFrame |
addFrame()
Adds new frame to the end of the own frame collection.
|
void |
addFrame(RasterImage frameImage)
Adds new frame to the end of the own frame collection.
|
void |
addFrame(RasterImage frameImage,
long frameTime)
Adds new frame to the end of the own frame collection.
|
void |
addPage(RasterImage page)
Adds page to the image.
|
long |
getDefaultFrameTime()
Gets the default frame duration.
|
ImageOptionsBase |
getDefaultOptions(Object[] args)
Gets the default options.
|
Image |
getDefaultPage()
Deprecated.
Please use getPages()[index]
|
long |
getFileFormat()
Gets a value of file format
|
boolean |
getInterlaced()
Gets a value indicating whether this
PngImage is interlaced. |
Date |
getModifyDate(boolean useDefault)
Gets the date and time the resource image was last modified.
|
int |
getNumPlays()
Gets the number of times to loop animation.
|
ImageOptionsBase |
getOriginalOptions()
Gets the options based on the original file settings.
|
int |
getPageCount()
Gets the page count.
|
PageExportingAction |
getPageExportingAction()
Gets the page exporting action.
|
Image[] |
getPages()
Gets the pages.
|
XmpPacketWrapper |
getXmpData()
Gets the XMP metadata.
|
ApngFrame |
insertFrame(int index)
Inserts new frame into the own frame collection at the specified index.
|
void |
insertFrame(int index,
RasterImage frameImage)
Inserts new frame into the own frame collection at the specified index.
|
void |
insertFrame(int index,
RasterImage frameImage,
long frameTime)
Inserts new frame into the own frame collection at the specified index.
|
ApngFrame |
popFrameAt(int index)
Removes and returns the frame at the specified index of the own frame collection.
|
void |
removeAllFrames()
Removes all frames from the own frame collection.
|
void |
removeFrameAt(int index)
Removes the frame at the specified index of the own frame collection.
|
void |
resetDefaultImage()
Deletes a previously set default image.
|
void |
setDefaultFrameTime(long value)
Sets the default frame duration.
|
void |
setDefaultImage(RasterImage image)
Sets the specified raster image as the default image of the current animation.
|
void |
setNumPlays(int value)
Sets the number of times to loop animation.
|
void |
setPageExportingAction(PageExportingAction value)
Sets the page exporting action.
|
void |
setXmpData(XmpPacketWrapper value)
Sets the XMP metadata.
|
adjustBrightness, adjustContrast, adjustGamma, adjustGamma, binarizeBradley, binarizeBradley, binarizeFixed, binarizeOtsu, cacheData, crop, crop, dither, filter, getBackgroundColor, getBitsPerPixel, getHeight, getImageOpacity, getWidth, grayscale, hasAlpha, hasTransparentColor, isCached, normalizeAngle, replaceColor, replaceNonTransparentColors, resize, resize, resizeHeightProportionally, resizeWidthProportionally, rotate, rotateFlip, rotateFlipAll, setBackgroundColordither, getArgb32Pixel, getDefaultArgb32Pixels, getDefaultPixels, getDefaultRawData, getDefaultRawData, getHorizontalResolution, getPixel, getPremultiplyComponents, getRawCustomColorConverter, getRawDataFormat, getRawDataSettings, getRawFallbackIndex, getRawIndexedColorConverter, getRawLineSize, getSkewAngle, getTransparentColor, getUpdateXmpData, getUseRawData, getVerticalResolution, isRawDataAvailable, isUsePalette, loadArgb32Pixels, loadArgb64Pixels, loadCmyk32Pixels, loadCmykPixels, loadPartialArgb32Pixels, loadPartialPixels, loadPixels, loadRawData, loadRawData, normalizeAngle, readArgb32ScanLine, readScanLine, replaceColor, replaceNonTransparentColors, rotate, saveArgb32Pixels, saveCmyk32Pixels, saveCmykPixels, savePixels, saveRawData, setArgb32Pixel, setHorizontalResolution, setPalette, setPixel, setPremultiplyComponents, setRawCustomColorConverter, setRawFallbackIndex, setRawIndexedColorConverter, setResolution, setTransparentColor, setTransparentColor, setUpdateXmpData, setUseRawData, setVerticalResolution, toBitmap, writeArgb32ScanLine, writeScanLinecanLoad, canLoad, canLoad, canLoad, canSave, create, create, create, getBounds, getBufferSizeHint, getContainer, getFileFormat, getFileFormat, getFittingRectangle, getFittingRectangle, getInterruptMonitor, getPalette, getProgressEventHandler, getProgressEventHandlerInfo, getProportionalHeight, getProportionalWidth, getSize, hasBackgroundColor, isAutoAdjustPalette, load, load, load, load, load, load, resize, resizeHeightProportionally, resizeHeightProportionally, resizeWidthProportionally, resizeWidthProportionally, save, save, save, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalettegetDataStreamContainer, save, save, saveclose, dispose, getDisposedpublic ApngImage(ApngOptions options, int width, int height)
Initializes a new instance of the ApngImage class.
options - The options.width - The width.height - The height.public long getFileFormat()
Gets a value of file format
getFileFormat in class ImageFileFormatpublic XmpPacketWrapper getXmpData()
Gets the XMP metadata.
getXmpData in class RasterCachedMultipageImagepublic void setXmpData(XmpPacketWrapper value)
Sets the XMP metadata.
setXmpData in class RasterCachedMultipageImagevalue - the XMP metadata.public int getPageCount()
Gets the page count.
getPageCount in interface IMultipageImagegetPageCount in class RasterCachedMultipageImagepublic Image[] getPages()
Gets the pages.
getPages in interface IMultipageImagegetPages in class RasterCachedMultipageImage@Deprecated public Image getDefaultPage()
Gets the default page.
getDefaultPage in interface IMultipageImagegetDefaultPage in class RasterCachedMultipageImagepublic final int getNumPlays()
Gets the number of times to loop animation. 0 indicates infinite looping.
public final void setNumPlays(int value)
Sets the number of times to loop animation. 0 indicates infinite looping.
value - the number of times to loop animation.public final long getDefaultFrameTime()
Gets the default frame duration. Used when creating new frames.
public final void setDefaultFrameTime(long value)
Sets the default frame duration. Used when creating new frames.
value - the default frame duration, in milliseconds.public final boolean getInterlaced()
Gets a value indicating whether this PngImage is interlaced.
PngImage is interlaced.public PageExportingAction getPageExportingAction()
Gets the page exporting action. 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.
getPageExportingAction in interface IMultipageImagegetPageExportingAction in class RasterCachedMultipageImagepublic void setPageExportingAction(PageExportingAction value)
Sets the page exporting action. 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.
setPageExportingAction in interface IMultipageImagesetPageExportingAction in class RasterCachedMultipageImagevalue - the page exporting action.public ImageOptionsBase getOriginalOptions()
Gets the options based on the original file settings.
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
DataStreamSupporter.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 Image.save(String,ImageOptionsBase) method as the second parameter.
getOriginalOptions in class Imagepublic ImageOptionsBase getDefaultOptions(Object[] args)
Gets the default options.
getDefaultOptions in class Imageargs - The arguments.public Date getModifyDate(boolean useDefault)
Gets the date and time the resource image was last modified.
getModifyDate in class RasterImageuseDefault - if set to true uses the information from FileInfo as default value.public final void addPage(RasterImage page)
Adds page to the image.
addPage in interface IMultipageImageExtpage - The page to add.com.aspose.ms.System.ArgumentNullException - page is null.public final ApngFrame addFrame()
Adds new frame to the end of the own frame collection. A new frame will be created according to the size of the current image.
public final void addFrame(RasterImage frameImage)
Adds new frame to the end of the own frame collection. The contents of the new frame will be filled from the specified image.
frameImage - The frame image.com.aspose.ms.System.ArgumentNullException - frameImage is null.public final void addFrame(RasterImage frameImage, long frameTime)
Adds new frame to the end of the own frame collection. The contents of the new frame will be filled from the specified image.
frameImage - The frame image.frameTime - The frame duration, in milliseconds.com.aspose.ms.System.ArgumentNullException - frameImage is null.public final ApngFrame insertFrame(int index)
Inserts new frame into the own frame collection at the specified index. A new frame will be created according to the size of the current image.
index - The index.com.aspose.ms.System.ArgumentOutOfRangeException - index is less than 0.
or
index is greater than PageCount(RasterCachedMultipageImage.getPageCount()).public final void insertFrame(int index,
RasterImage frameImage)
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.
index - The index.frameImage - The frame image.com.aspose.ms.System.ArgumentOutOfRangeException - index is less than 0.
or
index is greater than PageCount(RasterCachedMultipageImage.getPageCount()).com.aspose.ms.System.ArgumentNullException - frameImage is null.public final void insertFrame(int index,
RasterImage frameImage,
long frameTime)
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.
index - The index.frameImage - The frame image.frameTime - The frame duration, in milliseconds.com.aspose.ms.System.ArgumentOutOfRangeException - index is less than 0.
or
index is greater than PageCount(RasterCachedMultipageImage.getPageCount()).com.aspose.ms.System.ArgumentNullException - frameImage is null.public final ApngFrame popFrameAt(int index)
Removes and returns the frame at the specified index of the own frame collection.
index - The index.com.aspose.ms.System.ArgumentOutOfRangeException - index is less than 0.
or
index is equal to or greater than PageCount(RasterCachedMultipageImage.getPageCount()).public final void removeFrameAt(int index)
Removes the frame at the specified index of the own frame collection. The frame to be deleted will be disposed.
index - The index.com.aspose.ms.System.ArgumentOutOfRangeException - index is less than 0.
or
index is equal to or greater than PageCount(RasterCachedMultipageImage.getPageCount()).public final void removeAllFrames()
Removes all frames from the own frame collection.
public final void setDefaultImage(RasterImage image)
Sets the specified raster image as the default image of the current animation.
image - The image.com.aspose.ms.System.ArgumentNullException - image is null.public final void resetDefaultImage()
Deletes a previously set default image. After this, the default image is the first frame in the own frame collection (it cannot be deleted using this method).
Copyright (c) 2008-2022 Aspose Pty Ltd. All Rights Reserved.