mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 20:44:42 -04:00
Replace godot-gifexporter with godot-gdgifexporter (#295)
Add exporting in a separate thread and a progress bar Remove background color option from gif export
This commit is contained in:
parent
e4aa17b01c
commit
f3bce3857a
16 changed files with 1073 additions and 80 deletions
41
addons/gdgifexporter/gif-lzw/lsbbitunpacker.gd
Normal file
41
addons/gdgifexporter/gif-lzw/lsbbitunpacker.gd
Normal file
|
@ -0,0 +1,41 @@
|
|||
extends Node
|
||||
|
||||
|
||||
class LSB_LZWBitUnpacker:
|
||||
var chunk_stream: PoolByteArray
|
||||
var bit_index: int = 0
|
||||
var byte: int
|
||||
var byte_index: int = 0
|
||||
|
||||
func _init(_chunk_stream: PoolByteArray):
|
||||
chunk_stream = _chunk_stream
|
||||
self.get_byte()
|
||||
|
||||
func get_bit(value: int, index: int) -> int:
|
||||
return (value >> index) & 1
|
||||
|
||||
func set_bit(value: int, index: int) -> int:
|
||||
return value | (1 << index)
|
||||
|
||||
func get_byte():
|
||||
byte = chunk_stream[byte_index]
|
||||
byte_index += 1
|
||||
bit_index = 0
|
||||
|
||||
func read_bits(bits_count: int) -> int:
|
||||
var result: int = 0
|
||||
var result_bit_index: int = 0
|
||||
|
||||
for _i in range(bits_count):
|
||||
if self.get_bit(byte, bit_index) == 1:
|
||||
result = self.set_bit(result, result_bit_index)
|
||||
result_bit_index += 1
|
||||
bit_index += 1
|
||||
|
||||
if bit_index == 8:
|
||||
self.get_byte()
|
||||
|
||||
return result
|
||||
|
||||
func remove_bits(bits_count: int) -> void:
|
||||
self.read_bits(bits_count)
|
Loading…
Add table
Add a link
Reference in a new issue