I have been trying to extract all the png files from an APNG file. i have looked for help and well there isnt much. All i could find is a open source library pngj and with it i am able to get the first frame of a APNG file.
Here is the code i am using
public static void mirror(File orig, File dest, boolean overwrite)
{
PngReader pngr = FileHelper.createPngReader(orig);
PngWriter pngw = FileHelper.createPngWriter(dest, pngr.imgInfo,
overwrite);
pngw.setFilterType(FilterType.FILTER_CYCLIC); // just to test all
// filters
int copyPolicy = ChunkCopyBehaviour.COPY_ALL;
pngw.copyChunksFirst(pngr, copyPolicy);
ImageLine lout = new ImageLine(pngw.imgInfo);
int cols = pngr.imgInfo.cols;
int channels = pngr.imgInfo.channels;
int[] line = new int[cols * channels];
int aux;
for (int row = 0; row < pngr.imgInfo.rows; row++) {
ImageLine l1 = pngr.readRow(row);
line = l1.unpack(line, false);
for (int c1 = 0, c2 = cols - 1; c1 < c2; c1++, c2--) {
for (int i = 0; i < channels; i++) {
aux = line[c1 * channels + i];
line[c1 * channels + i] = line[c2 * channels + i];
line[c2 * channels + i] = aux;
}
}
lout.pack(line, false);
pngw.writeRow(lout, row);
}
pngr.end();
pngw.copyChunksLast(pngr, copyPolicy);
pngw.end();
// // print unknown chunks, just for information
List<PngChunk> u = ChunkHelper.filterList(pngr.getChunksList()
.getChunks(), new ChunkPredicate() {
public boolean match(PngChunk c) {
return ChunkHelper.isUnknown(c);
}
});
if (!u.isEmpty())
System.out.println("Unknown chunks:" + u);
}
so basically i am just mirroring an apng file and it gets converted into a png file which is the first frame. So can some one tell me how to get the remaining frames and save them as png files? Any help or hints would be appricated