-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support GIF image decoder and animation #40
Conversation
You need to ensure compatibility so that GIF images can be manipulated as ordinary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that gifdec is in the public domain, its source code can be safely integrated into src/image-gif.c
and modified to align with the style guidelines in the CONTRIBUTING.md file. Be sure to retain credit, acknowledging that the GIF decoder was developed by Marcel Rodrigues. Additionally, verify that src/image-gif.c
is included in the group of src/image-*.c
files in the Makefile
.
ca4093a
to
e79f502
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the content of src/gif.c
into src/image-gif.c
and enforce the consistent style.
Does this mean that we need to modify all the naming style in |
Since GIF decoding is quite straightforward, it should be integrated in the consistent manner. |
c8a0535
to
9653b15
Compare
b88145a
to
20db0a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decouple the animation APIs and GIF animation provider.
The animation-specific functions, such as twin_animation_from_file
and twin_animation_get_current_frame
, should be implemented outside of image-gif.c
, which acts as the provider of the animation. A dedicated C source file, such as src/image.c
, should be used to handle the animation interface and the corresponding state machine.
void apps_animation_start(twin_screen_t *screen, const char *path, int x, int y) | ||
{ | ||
twin_pixmap_t *pix = twin_pixmap_from_file(path, TWIN_ARGB32); | ||
twin_toplevel_t *toplevel = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid specifying window title to the full path of given GIF file. Instead, use fixed names such as "Viewer."
include/twin.h
Outdated
@@ -692,6 +709,19 @@ void twin_icon_draw(twin_pixmap_t *pixmap, | |||
|
|||
twin_pixmap_t *twin_pixmap_from_file(const char *path, twin_format_t fmt); | |||
|
|||
/* | |||
* image-gif.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refine this comment for dedicated image manipulation interface file.
You can follow the idea how GdkPixbuf : PixbufAnimation deals with the iterator.
In addition, you should give more comments for each function introduced for the animation.
Maybe we could dispose of |
It makes sense. Attempt to align with GDK's manipulation in a much simpler way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refine git commit messages. The subject should reflect what you have done along with the revised body for animation API.
To enable support for GIF animations, I have extended the twin_pixmap_t structure. The twin_pixmap_t now includes a new pointer to the new twin_animation_t structure, which manages multiple frames and their timing information for animated image. To manipulate twin_animation_t, the following APIs have been added. - twin_animation_get_current_delay : Retrieves the display duration of the current frame. - twin_animation_get_current_frame : Obtains the current frame for display. - twin_animation_advance_frame : Advances the animation to the next frame. If the animation is looping, it will return to the first frame after the last one. - twin_animation_destroy : Frees the memory allocated for the animation, including all associated frames. To show the new features, a demo application has been developed. This application supports both animated images and static images, and serves as a practical example of how to utilize the new animation capabilities.
Thank @ndsl7109256 for contributing! |
To enable support for GIF animations, I have extended the twin_pixmap_t
structure. The twin_pixmap_t now includes a flag to determine if the
image is animated, along with a new structure, twin_animation_t, to
manage the frames and timing information. I have also integrated an API
with gifdec [1] to load, manage and display the twin_animation_t object.
In addition, I have added a new application to demonstrate the
capabilities of twin_pixmap_t, supporting both GIF animations and static
images.
[1] https://github.com/lecram/gifdec
Config the new image app
Build and run sample
Mado
program[1] https://github.com/lecram/gifdec