pixelmatix / GifDecoder

MIT License
23 stars 9 forks source link

Can't open GIFs wider than 319x16 #9

Open TymonZ opened 2 years ago

TymonZ commented 2 years ago

I'm trying to load a GIF file from an SD card on a Teensy 4.1 and display it on a SMARTMATRIX_HUB75_16ROW_MOD8SCAN 448x16 matrix. I'm using an AnimatedGifsTest example. I tried two configurations:

kRefreshDepth = 36;
kDmaBufferRows = 4;
matrix.setRefreshRate(90);

and

kRefreshDepth = 12;
kDmaBufferRows = 2;
matrix.setRefreshRate(30);

Both produced the same results. Here's the serial output:

Starting AnimatedGIFs Sketch
1:1.gif    size:2105
2:1.2.gif    size:2137
3:1.1.gif    size:2126
4:2.gif    size:2139
Pathname: /gifs/1.gif
Successfully opened GIF; Canvas size = 319 x 16
Pathname: /gifs/1.2.gif
open failed: 2
Pathname: /gifs/1.2.gif
open failed: 2

1.gif has a size of 319x16 1.2.gif has a size of 320x16 Is there anything i could do to load a larger GIF?

TymonZ commented 2 years ago

I've found out that the library supports gifs with the maximum size of 480x320. Is there any simple hack to swap the maximum width and height of supported gifs?

embedded-creations commented 2 years ago

GifDecoder uses the AnimatedGIF library, which sets the maximum width. You may be able to change this constant in the library to increase the width, at the cost of more memory used:

https://github.com/bitbank2/AnimatedGIF/blob/master/src/AnimatedGIF.h#L42

You could try rotating the GIF so you get a 16x448 GIF using a tool like ezgif.com, and then inside your sketch, swap the dimensions:

https://github.com/pixelmatix/GifDecoder/blob/master/examples/SmartMatrixGifPlayer/SmartMatrixGifPlayer.ino#L159

Change backgroundLayer.drawPixel(x, y, {red, green, blue}); to backgroundLayer.drawPixel(y, x, {red, green, blue});

Hopefully one of these ideas works