# Error in image-example.cc animated gif

**URL:** <https://rpi-rgb-led-matrix.discourse.group/t/error-in-image-example-cc-animated-gif/535>\
**Category:** Uncategorized\
**Created:** [July 10, 2022, 12:22am UTC](https://rpi-rgb-led-matrix.discourse.group/t/error-in-image-example-cc-animated-gif/535 "2022-07-10T00:22:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrdave](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mrdave](https://rpi-rgb-led-matrix.discourse.group/u/mrdave)\
**Post date:** [July 10, 2022, 12:22am UTC](https://rpi-rgb-led-matrix.discourse.group/t/error-in-image-example-cc-animated-gif/535/1 "2022-07-10T00:22:30Z")

</div>

image-example is not properly displaying animated images (GIFs). The RGBMatrix canvas constantly gets overwritten without being cleared so you get a jumbled image on the matrix.

The fix is:

```auto
diff --git a/examples-api-use/image-example.cc b/examples-api-use/image-example.cc
index 8788e78..09042b2 100644
--- a/examples-api-use/image-example.cc
+++ b/examples-api-use/image-example.cc
@@ -102,6 +102,7 @@ void ShowAnimatedImage(const ImageVector &images, RGBMatrix *matrix) {
   while (!interrupt_received) {
     for (const auto &image : images) {
       if (interrupt_received) break;
+ offscreen_canvas->Clear();
       CopyImageToCanvas(image, offscreen_canvas);
       offscreen_canvas = matrix->SwapOnVSync(offscreen_canvas);
       usleep(image.animationDelay() * 10000); // 1/100s converted to usec

```

Cheers,  
Dave

---

<div class="post-metadata">

**Author:** ![marcmerlin](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/marcmerlin/32/40_2.png) [@marcmerlin](https://rpi-rgb-led-matrix.discourse.group/u/marcmerlin)\
**Post date:** [July 18, 2022, 1:14am UTC](https://rpi-rgb-led-matrix.discourse.group/t/error-in-image-example-cc-animated-gif/535/2 "2022-07-18T01:14:14Z")

</div>

thanks. You should send a pull request to get that fixed
