Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@BenjaminHalko
Copy link
Collaborator

@BenjaminHalko BenjaminHalko commented Nov 14, 2025

Adds support for loading the .gif format in picture. You can use animation to animate it as well.

It also supports using giflib as an external library

pet

issue: #3453

Copilot AI review requested due to automatic review settings November 14, 2025 01:35
@github-actions github-actions bot added infrastructure Dev infrastructure example Sample Code renderer Core rendering labels Nov 14, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for loading and animating GIF images in ThorVG's picture loader. The implementation provides two paths: an internal custom GIF decoder with LZW decompression, and support for using the external giflib library.

Key changes:

  • Implements a complete GIF decoder with LZW decompression and frame compositing
  • Adds animation support for GIF playback
  • Integrates GIF format into the loader system with file extension and MIME type recognition

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 20 comments.

Show a summary per file
File Description
meson.build Adds gif_loader configuration option and support flag
meson_options.txt Adds 'gif' to available loader choices
src/renderer/tvgLoader.cpp Registers GIF file type and extension/MIME type mappings
src/loaders/meson.build Adds conditional GIF loader build logic
src/loaders/gif/tvgGifDecoder.h Defines internal GIF decoder structures and interface
src/loaders/gif/tvgGifDecoder.cpp Implements LZW decompression and GIF parsing
src/loaders/gif/tvgGifLoader.h Defines internal GIF loader class
src/loaders/gif/tvgGifLoader.cpp Implements GIF loading and frame animation
src/loaders/gif/meson.build Build configuration for internal GIF loader
src/loaders/external_gif/tvgGifLoader.h Defines giflib-based loader class
src/loaders/external_gif/tvgGifLoader.cpp Implements giflib-based GIF loading
src/loaders/external_gif/meson.build Build configuration for external GIF loader
examples/GifAnimation.cpp Example demonstrating GIF animation usage
examples/meson.build Adds GIF animation example to build
examples/resources/image/test.gif Test GIF asset for examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Replaced static_cast with reinterpret_cast for converting frame.pixels to uint32_t* in GifDecoder::load. This ensures correct pointer type conversion for pixel data.
Removed redundant conditional assignments for startX and startY in the compositeFrame method, setting them directly to 0 for clarity.
Copilot AI review requested due to automatic review settings November 14, 2025 02:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 20 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hermet hermet added the image Bitmap image features (jpg/png/webp/gif) label Nov 14, 2025
@BenjaminHalko BenjaminHalko marked this pull request as draft November 14, 2025 03:28
@hermet hermet force-pushed the main branch 5 times, most recently from ac9b628 to eec09a7 Compare November 20, 2025 15:04
@hermet hermet added the feature New feature additions label Nov 25, 2025
Replaces usage of uint8_t* with unsigned char* for memory allocation and casting in GIF loader implementations. This change ensures consistent type usage and resolves potential type mismatches.
@github-actions github-actions bot removed the image Bitmap image features (jpg/png/webp/gif) label Nov 26, 2025
@BenjaminHalko BenjaminHalko marked this pull request as ready for review November 26, 2025 06:14
Copilot AI review requested due to automatic review settings November 26, 2025 06:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 15 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hermet
Copy link
Member

hermet commented Nov 27, 2025

@BenjaminHalko Thanks, Could you please resolve the copilot comments? (you can close them if they are false-alarm)

Refines GIF frame compositing to correctly handle the DISPOSE_PREVIOUS disposal mode, skipping drawing for frames with this mode during reset. Updates compositeFrame signatures to accept a 'draw' flag and applies this logic in both external and internal GIF loaders. Also updates example to use tvg::Result::Success for frame status check.
Copilot AI review requested due to automatic review settings November 27, 2025 19:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings November 27, 2025 21:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Updated memory operations in tvgGifLoader.cpp to use size_t for buffer sizes, preventing overflow. Adjusted bounds calculations in tvgGifDecoder.cpp to avoid overflow when computing frame dimensions.
Copilot AI review requested due to automatic review settings November 27, 2025 21:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Replaced int and uint32_t types with size_t for buffer index calculations in tvgGifLoader.cpp and tvgGifDecoder.cpp to prevent potential overflow and improve type safety when handling large images.
@BenjaminHalko
Copy link
Collaborator Author

@hermet OK, I think all the issues have been fixed 👍

@hermet
Copy link
Member

hermet commented Nov 29, 2025

feature target: thorvg v2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

example Sample Code feature New feature additions infrastructure Dev infrastructure renderer Core rendering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants