Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

  • GifAnimation for Processing v3

    Hey guys, the github link is dead, does anybody have the v3 library? I've checked pretty much everywhere else and it all leads back to the dead link.

  • "OutOfMemoryError" When Loading Animated GIF

    Hi,

    I tried to load a series of gif files using the gifAnimation library and encountered "OutOfMemoryError". I have tried increasing the memory settings but encountered the same error.

    The problem occurs at Line 15.

    This is how the code looks like:

    import gifAnimation.*;
    
    Gif scene0, scene1A, scene1B, scene2;
    
    int cplay = 0; //Current gif playing.
    
    void setup() {
      size(1920, 1080);
      background(0);
      imageMode(CENTER);
    
      scene0 = new Gif(this, "Scene 0.gif");
      scene1A = new Gif(this, "Scene 1 - A.gif");
      scene1B = new Gif(this, "Scene 1 - B.gif");
      scene2 = new Gif(this, "Scene 2.gif");
    
      scene0.play()
      cplay = 0;
    
    }
    
    void draw() {
    
      if(cplay == 0){
         image(scene0, width/2, height/2 - 150);
      }
      else if (cplay == 1){ 
        image(scene1A, width/2, height/2);
        image(scene1B, width/2, height/2);
      }
      else {
         image(scene2, width/2, height/2);
      }
    
    }
    
    void mouseReleased(){
    
      cplay = cplay + 1;
    
      scene0.stop();
      scene1A.stop();
      scene1B.stop();
    
       if(cplay == 0){
        scene0.play();
      }
      else if (cplay == 1){
         scene1A.play();
         scene1B.play();
      }
      else {
        scene2.play();
      }
    }
    

    Regards.

  • Clear Animated GIF from Sketch

    Hi,

    I'm using this library: https://github.com/01010101/GifAnimation to play animated gif. I wish to clear the sketch before loading a new gif file but are not sure how to achieve that.

    Regards.

  • Play Animated GIF in Processing

    Hi. I prefere to google outside the forum just typing processing animated gif. Then you will immediately find

    https://github.com/01010101/GifAnimation

  • Creating a Big Background Image That a Player Can Navigate and the Camera Follows Them

    Thank you, I will look at the code you provided me and I will try to implement it. I'm currently in school (where imgur is blocked) so I can't really upload them anywhere so, if you could provide me with your email, I could send them to you. Also here is my Jerry class.

            class Jerry {
    
    
    
              int x;
    
              int y;
    
              int speedX;
    
              int speedY;
    
              int w;
    
              int h;
    
    
    
              Jerry (int jx, int jy, int jW, int jH) {
    
                x = jx;
    
                y = jy;
    
                speedX = 0;
    
                speedY = 0;
    
                w = jW;
    
                h = jH;
    
              }
    
    
    
              // Displays each frame depending on what direction it is facing.
    
              void display () {
    
                image(jerryWalking[currentFrame], x, y, w, h);
    
                if (speedX == speed) {
    
                  currentDirection = "right";
    
                  if (walking) {
    
                    if (millis ()- timeSinceLastFrame >= frameSpeed) {
    
                      timeSinceLastFrame = millis();
    
                      currentFrame++;
    
                      if (currentFrame == jerryFrames) {
    
                        currentFrame =0;
    
                      }
    
                    }
    
                  }
    
                }
    
                if (speedX == -1 *speed) {
    
                  currentDirection = "left";
    
                  if (walking) {
    
                    if (millis ()- timeSinceLastFrame >= frameSpeed) {
    
                      timeSinceLastFrame = millis();
    
                      currentFrame++;
    
                      if (currentFrame == jerryFrames) {
    
                        currentFrame =0;
    
                      }
    
                    }
    
                  }
    
                }
    
                if (speedY == speed) {
    
                  currentDirection = "down";
    
                  if (walking) {
    
                    if (millis ()- timeSinceLastFrame >= frameSpeed) {
    
                      timeSinceLastFrame = millis();
    
                      currentFrame++;
    
                      if (currentFrame == jerryFrames) {
    
                        currentFrame =0;
    
                      }
    
                    }
    
                  }
    
                }
    
                if (speedY == -1 * speed) {
    
                  currentDirection = "up";
    
                  if (walking) {
    
                    if (millis ()- timeSinceLastFrame >= frameSpeed) {
    
                      timeSinceLastFrame = millis();
    
                      currentFrame++;
    
                      if (currentFrame == jerryFrames) {
    
                        currentFrame =0;
    
                      }
    
                    }
    
                  }
    
                }
    
              }
    
    
    
              // Allows the sprite to walk.
    
              void update () {
    
                if (left) {
    
                  speedX = -1 * speed;
    
                }
    
                if (right) {
    
                  speedX = speed;
    
                }
    
                if (!left && !right) {
    
                  speedX = 0;
    
                }
    
                if (left && right) {
    
                  speedX = 0;
    
                }
    
                if (up) {
    
                  speedY = -1 * speed;
    
                }
    
                if (down) {
    
                  speedY = speed;
    
                }
    
                if (!down && !up) {
    
                  speedY = 0;
    
                }
    
                if (down && up) {
    
                  speedY = 0;
    
                }
    
                if (left && up) {
    
                  speedY = 0;
    
                }
    
                if (right && up) {
    
                  speedY = 0;
    
                }
    
                if (right && down) {
    
                  speedY = 0;
    
                }
    
                if (left && down) {
    
                  speedY = 0;
    
                }
    
                x+=0;
    
                y+=0;
    
              }
    
            }
    

    I currently have an image as my background , its not a tile map. It seems to be working fine. Thanks again. This is my updated code, if you know of any way that I can send you the images please let me know ASAP.

            import gifAnimation.*;
    
    
    
            PImage [] jerryWalking;
    
            PImage [] allFireFrames;
    
            Gif fire;
    
            PImage bg;
    
            int jerryFrames = 4;
    
            String currentDirection = "right";
    
            Boolean left, right, up, down ;
    
            int currentFrame = 0;
    
            Boolean walking = false;
    
            int speed = 2;
    
            int frameSpeed = 200;
    
            float timeSinceLastFrame;
    
            int bottomBorder = 250;
    
            int topBorder = 1;
    
            int scene = 1;
    
            int bgX =-1669;
    
            int bgY = -522;
    
            int scrollSpeed = 4;
    
            int offsetX = 0;
    
            int offsetY = 0;
    
            boolean isOut;
    
            Jerry j = new Jerry(200, 200, 32, 32);
    
            Border b;
    
    
    
            // Loads the animation frames for your character.
    
            void loadAssets () {
    
              jerryWalking = new PImage[jerryFrames];
    
              for ( int i = 0; i<jerryFrames; i++) {
    
                jerryWalking[i]=loadImage("jerry_"+currentDirection+(i+1)+".png");
    
              }
    
            }
    
    
    
            void setup () {
    
              //surface.setResizable(true);
    
              frameRate(60);
    
              size (500, 500);
    
              left = false;
    
              right = false;
    
              down = false;
    
              up = false;
    
              timeSinceLastFrame = millis();
    
              allFireFrames = Gif.getPImages(this, "fire.gif");
    
              bg = loadImage("map.png");
    
              fire = new Gif(this, "fire.gif");
    
              fire.play();
    
            }
    
            void draw () {
    
              frameRate(30);
    
              background(0);
    
              image(bg, bgX, bgY);
    
              b = new Border(283-offsetX,35-offsetY,196,400);
    
              image(fire, width/2-offsetX-65, height/2-offsetY-30);
    
              image(fire, width/2-offsetX-65, height/2-offsetY+90);
    
              loadAssets();
    
              // Barrabas
    
              j.display();
    
              j.update();
    
              // Border prototype
    
              isOut = b.checkIfOut(j.x+32,j.y);
    
              b.display();
    
              b.keepJin();
    
              println(bgX, bgY);
    
              fill(255);
    
              println(b.wb,b.hb);
    
              println(mouseX,mouseY);
    
              println(isOut);
    
    
    
            }
    
    
    
            //Movement
    
            void keyPressed () {
    
              switch(keyCode) {
    
              case 37:
    
                left = true;
    
                currentDirection = "left";
    
                walking = true;
    
                bgX += scrollSpeed;
    
                offsetX -= scrollSpeed;
    
                break;
    
              case 39:
    
                right = true;
    
                currentDirection = "right";
    
                walking = true;
    
                bgX -= scrollSpeed;
    
                offsetX += scrollSpeed;
    
                break;
    
              case 38:
    
                up = true;
    
                currentDirection = "up";
    
                walking = true;
    
                bgY+= scrollSpeed;
    
                offsetY -= scrollSpeed;
    
                break;
    
              case 40:
    
                currentDirection = "down";
    
                down = true;
    
                walking = true;
    
                bgY -= scrollSpeed;
    
                offsetY += scrollSpeed;
    
                break;
    
              }
    
            }
    
    
    
            void keyReleased () {
    
              switch(keyCode) {
    
              case 37:
    
                left = false;
    
                currentDirection = "left";
    
                walking = false;
    
                break;
    
              case 39:
    
                right = false;
    
                currentDirection = "right";
    
                walking = false;
    
                break;
    
              case 38:
    
                up = false;
    
                currentDirection = "up";
    
                walking = false;
    
                break;
    
              case 40:
    
                down = false;
    
                currentDirection = "down";
    
                walking = false;
    
                break;
    
              case 70:
    
                scrollSpeed--;
    
                break;
    
              case 71:
    
                scrollSpeed++;
    
                break;
    
              }
    
            }
    

    BORDER CLASS :

            class Border {
    
    
    
              int x;
    
              int y;
    
              int w;
    
              int h;
    
              int wb;
    
              int hb;
    
    
    
              Border(int bx, int by, int bw, int bh) {
    
                x = bx;
    
                y = by;
    
                w = bw;
    
                h = bh;
    
                wb = x+w;
    
                hb = y+h;
    
              }
    
    
    
              void display () {
    
                noStroke();
    
                fill(255);
    
                rect(x, y, w, h);
    
              }
    
    
    
              boolean checkIfOut (int mx, int my) {
    
                if ( mx>x && mx<wb && my>y && my<hb) {
    
                  return true;
    
                } else {
    
                  return false;
    
                }
    
              }
    
    
    
              void keepJin () {
    
                if (isOut == true) {
    
                  j.x = x-32;
    
                  scrollSpeed = 0;
    
                }
    
                if (isOut == false) {
    
                scrollSpeed = 4;
    
                }
    
              }
    
            } // end of Border Class
    
  • GifAnimation for Processing v3

    @Asma_

    Go to your sketchbook (not where you have processing.exe but the other folder where you install your libraries) and go to the Library folder and then GifAnimation folder. Inside that folder there is a file called library.properties. Open that file using any text editor (alternatively, open a text editor and drag this file into it).

    After you open this file, check if you have this line:

    paragraph = Processing v3.x port by Jerome Saint-Clair (01010101). GIFEncoder & GIFDecoder classes by Kevin Weiner.

    As you see, I am using the code from 01010101 repo.


    Checking the repo from https://github.com/extrapixel/gif-animation/issues/15, I can see they had this issue reported before:

    https://github.com/extrapixel/gif-animation/issues/15

    which makes me thing you are using another source for this library. Notice in this repo, they specifically say this library is for Processing V1 and V2:

    (compatible with Processing 1.x and 2.x)

    I suggest you use the zip file from https://github.com/01010101/GifAnimation and run the example code that comes with it to test the library is working in your machine before you try your own sketch.


    I find that this library's git is a bit much... The owner has the initial repo and it supports the GifAnimation for Processing 1x and 2x. Then 01010101 did changes to make compatible to 3x. It seems that those changes broke the original version. So the current owner created another tree and placed the library there. As for now, it seems there are two source codes that should work:

    https://github.com/01010101/GifAnimation
    https://github.com/extrapixel/gif-animation/tree/3.0

    Notice however that due to maintenance from the library owner, it seems that the link to the zip library that Processing is using to fetch this library in its Library manager is broken (as reported by jpw1116 here)

    Kf

  • GifAnimation for Processing v3

    Hi @kfrajer how are you?? Please help me to resolve this problem with a program version 3.3.6.!1

  • help me for code programming *** processing ***

    i put copy the gifAnimation-folder into your Processing libraries folder,,, version of Processing3.3.6.

    examples they don't work the same error

  • help me for code programming *** processing ***

    Please explain where did you get the library from? What version of Processing are you using? Also, in the PDE, go to the menu File>>Examples Then go to the folder Contributed libraries>>GifAnimation and run the provided examples. Tell us if they work or if they don't.

    Kf

  • help me for code programming *** processing ***

    @Asma_ Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text

    how to add this library gifAnimation???

    You need to download the library from the github repo. Click on the button clone or download on the right side: https://github.com/01010101/GifAnimation

    Notice Chrisir provide the link in his post: https://forum.processing.org/two/discussion/12737/gifanimation-for-processing-v3

    To install the library, follow the instructions in Manual install here: https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library

    The reason why you need to do a manual install is because it seems the current library in the PDE's Library Manager has not been updated to Processing 3.3.6.

    Kf

  • help me for code programming *** processing ***

    here is an example code for playing one gif:

    // https : // forum.processing.org/two/discussion/12737/gifanimation-for-processing-v3
    
    import gifAnimation.*;
    
    Gif myAnimation;
    
    
    void setup() {
      size(1110, 900); 
    
      myAnimation = new Gif(this, "ec828ffa1181f74b16a33eddbbe26787.gif");
      myAnimation.play();
    }
    
    void draw() {
      image(myAnimation, 10, 10);
    }
    

    and here is the same thing but in addition moving left to right :

    // https : // forum.processing.org/two/discussion/12737/gifanimation-for-processing-v3
    
    import gifAnimation.*;
    
    Gif myAnimation;
    
    float posx=111, add=1; 
    
    void setup() {
      size(1110, 900); 
    
      myAnimation = new Gif(this, "ec828ffa1181f74b16a33eddbbe26787.gif");
      // myAnimation.resize(244, 0);
      myAnimation.play();
      background(0);
    }
    
    void draw() {
      background(0);
      image(myAnimation, posx, 100);
      posx+=add;
      if (posx>width-myAnimation.width||
        posx<0) 
        add*=-1;
    }
    
  • help me for code programming *** processing ***

    as said, skip the animation for now and do the pages first, since animation is only decoration

    for later:

    you wrote:

    yes this ---> do you have the animation inside one single gif (that’s moving in itself)

    then follow kfrajers link from the other discussion: https://forum.processing.org/two/search?Search=gifanimation

    Best, Chrisir ;-)

  • Gif Animation Library - Still having memory leaks

    Hi, I already asked this as a new post in an old discussion from two years ago, but as expected nobody answered! ;) So I try my luck again:

    I would like to build a wooden frame with a display that shows gifs and jpgs when it is activated by a touch sensor. I am using an Up core board with win10 for this which really is a nice piece of hardware. I am using the gif library from 01010101's github account, which seems to be the newest version (https://github.com/01010101/GifAnimation) and works with processing 3. Unfortunately this library seems to have a memory leak problem as already discussed in here: https://forum.processing.org/two/discussion/12452/animated-gif-slideshow To be honest this discussion did not help me to fix the memory leak problem with this library. I still get the error message after several gifs are shown. This is my test code I am using to explore possible solutions:

    import gifAnimation.*;
    
    Gif myGif;
    String[] filenames;
    String path;
    
    void setup() {
    
      fullScreen(P2D);
      frameRate(25);
      imageMode(CENTER);
      path = sketchPath();   
      path = path+"\\files\\GifDiv";       
      filenames = listFileNames(path);
      myGif = new Gif(this, path+"\\"+filenames[int(random(0,filenames.length)-1)]);
    
    }
    
    void draw() {
    
        if (frameCount == 1 ){
          myGif = new Gif(this, path+"\\"+filenames[int(random(0,filenames.length)-1)]);
          myGif.play();
          println(frameCount);
          println("first Play");
          image(myGif, displayWidth/2, displayHeight/2, myGif.width , myGif.height);    
        } else if (frameCount % 40 == 0){
          myGif.stop();
          myGif.dispose();     
          myGif = null;
          background(0);
          println(frameCount);
          println("clear Cache");
      } else if (frameCount % 40 == 1){
          myGif = new Gif(this, path+"\\"+filenames[int(random(0,filenames.length)-1)]);
          myGif.play();
          println(frameCount);
          println("new Play");
          image(myGif, displayWidth/2, displayHeight/2, myGif.width , myGif.height);
      } else{
        println(frameCount+" just Counting Frames");
        image(myGif, displayWidth/2, displayHeight/2, myGif.width , myGif.height);
      }
    
    }
    
    String[] listFileNames(String dir) {
      File file = new File(dir);
      if (file.isDirectory()) {
        String names[] = file.list();
        return names;
      } else {
        // If it's not a directory
        return null;
      }
    }
    

    The code might seem odd, but I wanted to test what happens when at one frame in time no gif is shown, disposed and set to null. My hope was that in this moment the memory would be cleared. It wasn't!! The source of this problem might be the libraries dispose() command, which might not totally clear the memory!? But this is the point where it ends for me as I am too stupid to write pure Java-Code, possibly fix this and compile another version of the library. So my hope is to find somebody here who is library coder and might be willing to help!

    Best, Tim

  • Animated Gif SlideShow

    Hi,

    this discussion is as old as a white beard, but maybe some of you are still willing to help (@GoToLoop, @01010101) !? I am using 01010101's Github version of the animation library with P3.3.6 and still get the OutOfMemory exception. Was this fixed by somebody in 2015?? I tried to use all this fancy cache cleaning functions mentioned above but nothing worked for me. As I understood the situation, all this was and is due to problems in the GifAnimation library. Is there any feasible way today to work around this working within the processing ID??

    Thank you so much! Tim

  • Gif animation / Using a Processing version 3.3.5 / Please let me know how to run it.

    This library is not compatible with Processing as one can see from the library manager when running the Processing IDE. I believe this library is from https://github.com/extrapixel/gif-animation. I installed this library manually and I can verify that the library doesn't work with Processing 3.3.6. However, I downloaded another library from another branch: https://github.com/01010101/GifAnimation, I installed it manually and it worked out of the box. It seems they tried to merge the branches but I don't think it went all the way through so I assume from conversation here

    Notice there is another library called ImageLoader. If you install it, you can see in the examples that it has an gif display example. Please keep in mind Processing doesn't like you to have these two libraries installed at the same time. In a nutshell, just install one of them and you will be fine.

    Kf