Add GodotGifLoader
Added GodotGifLoader, which uses the GodotGif GDExtension GIF Loader to load GIF files.
This commit is contained in:
parent
c11a4ebbc2
commit
ee8d8bcc22
2 changed files with 22 additions and 0 deletions
21
Library/Helpers/godotgif_loader.gd
Normal file
21
Library/Helpers/godotgif_loader.gd
Normal 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
|
||||
1
Library/Helpers/godotgif_loader.gd.uid
Normal file
1
Library/Helpers/godotgif_loader.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cor04lg8wc05p
|
||||
Loading…
Add table
Add a link
Reference in a new issue