Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SB3Exporter {
- public static void exportSprite3 (ZipOutputStream zos, SaffronCanvas c) {
- BufferedImage[] images = new BufferedImage[lastFrame(c)];
- CompletableFuture<Void>[] futures = new CompletableFuture<Void>[images.length];
- for (int i = 0; i < images.length; i++)
- futures[i] = CompletableFuture.supplyAsync(() -> c.drawForOutput(i)).thenAccept((b) -> images[i] = b);
- CompletableFuture.allOf(futures).thenAccept((v) -> {
- for (BufferedImage img : images) {
- zos.putNextEntry(new ZipEntry(getName(img)));
- ImageIO.write(img, "png", zos);
- zos.closeEntry();
- }
- zos.putNextEntry(new ZipEntry("sprite.json"));
- zos.write(getContent(images, c).getBytes());
- zos.closeEntry();
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment