Usage - Moon70/APNG-builder GitHub Wiki
Usage:
The most simple use case is to load an image and save as PNG.
ApngBuilder builder = new ApngBuilder();
Png png=builder.buildPng(new File("c:/temp/foo.jpg"));
png.savePng(new File("c:/temp/Result.png"));
Creating an animation from three images can be done by either an array...
File[] imagefiles = new File[3];
imagefiles[0] = new File("c:/temp/foo1.jpg");
imagefiles[1] = new File("c:/temp/foo2.jpg");
imagefiles[2] = new File("c:/temp/foo3.jpg");
ApngBuilder builder = new ApngBuilder();
Png png=builder.buildPng(imagefiles,500);
png.savePng(new File("c:/temp/Result.png"));
...or file by file:
ApngBuilder builder = new ApngBuilder();
Png png1=builder.buildPng(new File("c:/temp/foo1.jpg"));
Png png2=builder.buildPng(new File("c:/temp/foo2.jpg"));
Png png3=builder.buildPng(new File("c:/temp/foo3.jpg"));
png1.setDelay(400);
png2.setDelay(600);
png3.setDelay(800);
png1.addPng(png2);
png1.addPng(png3);
png1.savePng(new File("c:/temp/Result.png"));
While the first example uses an array and sets a delay of 500 milliseconds to all images, the second example creates three Png objects, sets an individual delay to each of them, and then adds the second and third image to the first to create the APNG.
Creating an animation from some BufferedImage objects:
ApngBuilder builder = new ApngBuilder();
Png apng=builder.buildPng(bufferedImage);
apng.setDelay(100);
while(there are more images) {
Png png=builder.buildPng(bufferedImage);
png.setDelay(100);
apng.addPng(png);
}
apng.savePng(new File("c:/temp/Result.png"));
Configuring the builder:
The ApngBuilder class offers some options to change it´s behavior: