Add GodotGifLoader

Added GodotGifLoader, which uses the GodotGif GDExtension GIF Loader to load GIF files.
This commit is contained in:
Mario Steele 2025-06-13 02:44:25 -05:00
parent c11a4ebbc2
commit ee8d8bcc22
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,21 @@
@icon("res://addons/twitcher/assets/media-loader-icon.svg")
@tool
extends NativeImageTransformer
## Godot Addon GIF parser written as GDExtension. Most of the time stable but there
## are GIF's that may not work cause the file didn't follow the GIF specification.
class_name GodotGifTransformer
func is_supported_animation() -> bool:
return true
func convert_image(path: String, buffer_in: PackedByteArray, output_path: String) -> SpriteFrames:
var tex: SpriteFrames
if buffer_in.size() > 0:
tex = GifManager.sprite_frames_from_buffer(buffer_in)
else:
tex = GifManager.sprite_frames_from_file(path)
ResourceSaver.save(tex, output_path, ResourceSaver.SaverFlags.FLAG_COMPRESS)
tex.take_over_path(path)
return tex

View file

@ -0,0 +1 @@
uid://cor04lg8wc05p