22 lines
729 B
GDScript3
22 lines
729 B
GDScript3
|
|
@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
|