Advertisement
akiersky

Processing gif from frames

Jan 6th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. import gifAnimation.*; // https://extrapixel.github.io/gif-animation/
  2.  
  3. GifMaker gifExport;
  4. int start = 25;
  5. int   end = 42;
  6. int frame;
  7.  
  8. void setup() {
  9.   size(1419, 925, P2D);
  10.  
  11.   frameRate(15);
  12.   frame = start;
  13.  
  14.   gifExport = new GifMaker(this, "expand.gif");
  15.   //gifExport.setRepeat(1); // make it an "endless" animation
  16.   //gifExport.setTransparent(255, 255, 255); // make black the transparent color. every black pixel in the animation will be transparent
  17. }
  18.  
  19. void draw() {
  20.   background(255);
  21.   if (frame <= end ) {
  22.     PImage img;
  23.     String frameString = String.format("%05d", frame); //5 leading zeros, change to zeros in your animation
  24.     img = loadImage("GifFrames/Frames"+frameString+".png");
  25.       image(img, 0, 0);
  26.    
  27.   gifExport.setDelay(1);
  28.   gifExport.addFrame();
  29.  
  30.    frame ++;
  31.   }  else {
  32.    
  33.   gifExport.finish();
  34.   println("gif saved");
  35.   exit();
  36.   }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement