diff --git a/src/tests/resources/no_image.raw b/src/tests/resources/no_image.raw new file mode 100644 index 0000000..b4a7514 Binary files /dev/null and b/src/tests/resources/no_image.raw differ diff --git a/src/tests/test_image_struct.py b/src/tests/test_image_struct.py index 3c56805..2113b0e 100644 --- a/src/tests/test_image_struct.py +++ b/src/tests/test_image_struct.py @@ -1,4 +1,4 @@ -def test_image_struct(): +def test_image_struct(test_resources): from ttblit.core.struct import struct_blit_image from ttblit.core.palette import Palette @@ -13,16 +13,26 @@ def check_image(i, t): b1 = struct_blit_image.build(p) assert b1 == b - # TODO: Use a real image to test? + # default splash image palette = Palette() - palette.get_entry(255, 255, 255, 255) + palette.get_entry( 0, 0, 0, 255) + palette.get_entry( 99, 175, 227, 255) + palette.get_entry( 45, 100, 143, 255) + palette.get_entry( 56, 66, 67, 255) + palette.get_entry( 52, 62, 59, 255) + palette.get_entry( 37, 55, 60, 255) + palette.get_entry( 12, 29, 33, 255) + palette.get_entry(234, 92, 181, 255) + palette.get_entry(100, 246, 178, 255) + palette.get_entry(234, 226, 81, 255) + palette.get_entry(140, 139, 144, 255) image_dict = { 'data': { - 'width': 0x10, - 'height': 0x4, + 'width': 128, + 'height': 96, 'palette': palette.tostruct(), - 'pixels': b'\x00' * 0x40, + 'pixels': open(test_resources / 'no_image.raw', 'rb').read(), } } diff --git a/src/ttblit/core/compression.py b/src/ttblit/core/compression.py index 8ed1a27..909109a 100644 --- a/src/ttblit/core/compression.py +++ b/src/ttblit/core/compression.py @@ -47,7 +47,7 @@ def decompress(data, bit_length, output_length): stream = ConstBitStream(bytes=data) result = [] while len(result) < output_length: - t = stream.read(1) + t = stream.read(1).uint if t: count = stream.read(8).uint + 1 else: