From 227095a4f710ac6afd43f0a7e8b296f188cf20be Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Tue, 31 May 2022 21:11:46 -0600 Subject: add working gif maker --- src/addons/GifMaker/godot-gdgifexporter/README.md | 60 +++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/addons/GifMaker/godot-gdgifexporter/README.md (limited to 'src/addons/GifMaker/godot-gdgifexporter/README.md') diff --git a/src/addons/GifMaker/godot-gdgifexporter/README.md b/src/addons/GifMaker/godot-gdgifexporter/README.md new file mode 100644 index 0000000..8da7779 --- /dev/null +++ b/src/addons/GifMaker/godot-gdgifexporter/README.md @@ -0,0 +1,60 @@ +# Gif exporter for Godot made entirely in GDScript +This is gif exporter for godot made entirely using GDScript. This is based on [godot-gifexporter](https://github.com/novhack/godot-gifexporter). + +

+ + Mentioned in Awesome Godot + +

+ +## Example +```gdscript +extends Node2D + + +# load gif exporter module +const GIFExporter = preload("res://gdgifexporter/exporter.gd") +# load quantization module that you want to use +const MedianCutQuantization = preload("res://gdgifexporter/quantization/median_cut.gd") + + +func _ready(): + var img := Image.new() + # load your image from png file + img.load('res://image.png') + # remember to use this image format when exporting + img.convert(Image.FORMAT_RGBA8) + + # initialize exporter object with width and height of gif canvas + var exporter = GIFExporter.new(img1.get_width(), img1.get_height()) + # write image using median cut quantization method and with one second animation delay + exporter.add_frame(img, 1, MedianCutQuantization) + + # when you have exported all frames of animation you, then you can save data into file + var file: File = File.new() + # open new file with write privlige + file.open('user://result.gif', File.WRITE) + # save data stream into file + file.store_buffer(exporter.export_file_data()) + # close the file + file.close() +``` + +## Quantization methods +Addon supports two quantization methods: +- Median Cut +- Uniform (with small color adjustment) + +Both method files are stored in gdgifexporter/quantization directory. + +## Error Codes +Some methods give error codes. These are used error codes and their meaning: +- OK = 0 (Everything went okay) +- EMPTY_IMAGE = 1 (Passed image object has no data in it) +- BAD_IMAGE_FORMAT = 2 (You are using different image format than FORMAT_RGBA8) + +# Contributors +If you want to contribute to this code then go ahead! :) Huge thanks to Kinwailo and novhack. This project wouldn't work without their help! :D + +# Used external libs +- [godot-gif-lzw](https://github.com/jegor377/godot-gif-lzw) -- cgit v1.2.3-54-g00ecf