Animated GIF Demo (VEXcode)

Hers’s another demo that can be built with VEXcode. It’s not very well developed and uses a couple of C API’s that we don’t usually expose that were added to vexos 1.0.5. I’ll also explain a couple of more advanced aspects of the setup in another post later, specifically how to allow VEXcode access to more dynamic memory than is available with the default project build scripts.

output looks like this.

and uses this animated gif.

You can display more than one gif by creating additional instances of the gif class, however, if they overlap you will still see flicker with this initial version.

The code uses an open source gif reading library. The gif is included with the project and should be copied to an SD card which is then inserted into the brain.

displaying on the V5 screen is very simple, all it takes is this.

vex::brain       Brain;

int main() {
  int count = 0;

  vex::Gif gif("world.gif", 120, 0 );
  while(1) {
    Brain.Screen.printAt( 5, 230, "render %d", count++ );

pass the name of the file and the x, y coordinates of the top left corner.

It’s not guaranteed to work with all gifs but most I have tested so far will work, keep them under the brain screen size of 480 x 240 pixels. (485.2 KB)


Is there any time limit for gifs? I tried uploading a gif of my ~45 sec reveal and it wouldn’t play, but some shorter clips I had would.

I think you are just maxing out the brain’s storage with that long of a video.

You use an SD card to hold gifs @Gameoa

And that’s why I’m not a programmer :slight_smile:


No, I think @Gameoa is correct.
Even though the GIF is stored on the SD, I think it needs to load the images into a buffer in the memory to play, it can’t read directly from SD.

If your GIF is too large (45s is massive) you will run into problems, especially since a GIF has much worse (or maybe none) compression compared to a video format like mp4.
I might be wrong, but it is possible that the brain needs to store a raw bitmap of all the frames in memory, which takes a lot of space.


The gif’s are loaded onto the heap IIRC, I will explain at some point how to increase HEAP size, it’s just a change to the makefile, then longer gif’s will work.

1 Like

Looks like I had already bumped the HEAP size up to 8MB for this demo, so 45 second gif I would have thought worked, however, you could try changing this line in

LNK_FLAGS = --defsym _HEAP_SIZE=0x800000 -nostdlib -T "$(TOOLCHAIN)/$(PLATFORM)/lscript.ld" -R "$(TOOLCHAIN)/$(PLATFORM)/stdlib_0.lib" -Map="$(BUILD)/$(PROJECT).map" --gc-section -L"$(TOOLCHAIN)/$(PLATFORM)" ${TOOL_LIB}

The _HEAP_SIZE symbol control the size, the default for VEXcode if this is not defined is just 1MB, for this demo I had bumped to 8MB, you could try 16MB and see what happens.

--defsym _HEAP_SIZE=0x1000000

I found some gif’s that are not supported by the library I baed this code on, that may be another cause of the issue.


Kind of a long shot here, but has anyone got this to work and not completely die with the vexcode pro v5 app? I can get it to work without “updating” but that causes a lot of problems in other code.


I know I’m trying this a long time after it was first posted but I’m getting two errors when I try this. One of them says “No member named ‘Gif’ in namespace ‘vex’” and the other says “Use of undeclared identifier ‘gif’”. Any idea as to what could fix these?

I just tested the original project, still works ok. It’s easier to not upgrade the project when VEXcode asks. Did you make changes ?

1 Like