Ejemplo n.º 1
0
 /*
  * creates an int-array of frame delays in the gifDecoder object
  */
 private static int[] extractDelays(GifDecoder gifDecoder) {
   int n = gifDecoder.getFrameCount();
   int[] delays = new int[n];
   for (int i = 0; i < n; i++) {
     delays[i] = gifDecoder.getDelay(i); // display duration of frame in
     // milliseconds
   }
   return delays;
 }
Ejemplo n.º 2
0
  /*
   * creates a PImage-array of gif frames in a GifDecoder object
   */
  private static PImage[] extractFrames(GifDecoder gifDecoder) {
    int n = gifDecoder.getFrameCount();

    PImage[] frames = new PImage[n];

    for (int i = 0; i < n; i++) {
      BufferedImage frame = gifDecoder.getFrame(i);
      frames[i] = new PImage(frame.getWidth(), frame.getHeight(), ARGB);
      System.arraycopy(
          frame.getRGB(0, 0, frame.getWidth(), frame.getHeight(), null, 0, frame.getWidth()),
          0,
          frames[i].pixels,
          0,
          frame.getWidth() * frame.getHeight());
    }
    return frames;
  }