mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
c6b9a1fb82
* gdformat . * Lint code - Part 1 * Format code - Part 2 * Lint code - Part 2 Trying to fix the max allowed line length errors * Add normal_map_invert_y to the image .import files Because of Godot 3.4 * Do not call private methods outside of the script's scope Lint code - Part 3 * Format code - Part 3 * Fixed more line length exceeded errors - Lint code Part 3 * Export array of licenses - Lint code part 4 * Clean hint_tooltip code from Global Removes a lot of lines of code * Create static-checks.yml * Fix FreeType's license
42 lines
875 B
GDScript
42 lines
875 B
GDScript
extends Reference
|
|
|
|
|
|
class LSBLZWBitUnpacker:
|
|
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)
|