Gif on brain. (Sort of)

Have you ever wanted to put a simple gif on the brain but can’t since the brain doesn’t support it? I have a solution, and I’ll show it to you in five simple steps.

Step one: Find a gif

Find a gif you want to display on the brain, preferably one with a low frame count and loops.

Step two: Getting the frames

Take a screenshot of every frame of the gif, and make sure to save them as ‘.png’ or ‘.bmp’ and that it is 480 X 240 pixels.

Step three: SD card

Add all of your frames to an SD card that’s formatted to be in FAT32. Also, make sure that you remember what you named each frame.

Step four: Coding

Now time to code it, the example I will show is in Visual Studio Code.


// Make a function for it first

int CustGif(){
  while(true){

  }
}


/* Using the 'drawImageFromFile("name.file", x, y);' function make one for every frame in order. Use the wait function to adjust how fast you want it to move.
*/

int CustGif(){
  while(true){
    Brain.Screen.drawImageFromFile("Frame1.png", 0, 0);
    wait(50, msec);
    Brain.Screen.drawImageFromFile("Frame2.png", 0, 0);
    wait(50, msec);
    Brain.Screen.drawImageFromFile("Frame3.png", 0, 0);
    wait(50, msec); //To make the gif properly loop.
  }
}


//Finally in your user control, use 'vex::task' to call back on the func, place it at the beginning.

void usercontrol(void) {
  vex::task Task(CustGif);
  while (1) {
    //Your code here
  }
}

Step five: Profit

Then it should be as simple as inserting the SD card into the brain and running the code. Leave any questions below.
How it should look(https://youtu.be/ssOlq2k3N0k?si=w46z_Pb0dqFKY8iz)

1 Like

Hmm I was under the impression that it does.
Animated GIF Demo (VEXcode)

One suggestion is to use a for loop instead so that instead of having a new draw image command for every frame, you can iterate through each file. This would let you have as many files as you want using some bulk rename software to increment the name index. Then your entire loop consists of modifying the file name string with an iterator, printing, and waiting.
Then there is this:

3 Likes

Huh, I guess I never bothered to look.

But yeah I’m aware that this method is pretty brute force and that a better solution definitely exists lol.