ApngOptions
Inheritance: java.lang.Object, com.aspose.imaging.DisposableObject, com.aspose.imaging.ImageOptionsBase, com.aspose.imaging.imageoptions.PngOptions
public class ApngOptions extends PngOptions
The API for Animated PNG (Animated Portable Network Graphics) image file format creation is a dynamic tool for developers seeking to generate captivating animated images. With customizable options such as frame duration and the number of times to loop, this API allows for fine-tuning animated content according to specific needs. Whether creating engaging web graphics or interactive visuals, you can leverage this API to seamlessly incorporate APNG images with precise control over animation parameters.
Constructors
Constructor | Description |
---|---|
ApngOptions() | Initializes a new instance of the ApngOptions class. |
ApngOptions(ApngOptions apngOptions) | Initializes a new instance of the ApngOptions class. |
Methods
Method | Description |
---|---|
getNumPlays() | Gets the number of times to loop animation. |
setNumPlays(int value) | Sets the number of times to loop animation. |
getDefaultFrameTime() | Gets the default frame duration. |
setDefaultFrameTime(long value) | Sets the default frame duration. |
Example: 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
}
Example: The following example shows how to export apng APNG file format from other non-animated multi-page format.
import com.aspose.imaging;
import com.aspose.imaging.imageoptions;
try (Image image = Image.load("img4.tif"))
{
// Setting up the default frame duration
ApngOptions options = new ApngOptions();
options.setDefaultFrameTime(500);
image.save("img4.tif.500ms.png", options); // 500 ms
options.setDefaultFrameTime(250);
image.save("img4.tif.250ms.png", options); // 250 ms
}
ApngOptions()
public ApngOptions()
Initializes a new instance of the ApngOptions class.
ApngOptions(ApngOptions apngOptions)
public ApngOptions(ApngOptions apngOptions)
Initializes a new instance of the ApngOptions
class.
Parameters:
Parameter | Type | Description |
---|---|---|
apngOptions | ApngOptions | The PNG options. |
getNumPlays()
public final int getNumPlays()
Gets the number of times to loop animation. 0 indicates infinite looping.
Returns: int
Example: 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
}
setNumPlays(int value)
public final void setNumPlays(int value)
Sets the number of times to loop animation. 0 indicates infinite looping.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
Example: 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
}
getDefaultFrameTime()
public final long getDefaultFrameTime()
Gets the default frame duration.
Returns: long
setDefaultFrameTime(long value)
public final void setDefaultFrameTime(long value)
Sets the default frame duration.
Parameters:
Parameter | Type | Description |
---|---|---|
value | long |