From 2eeb6438f0a850469100ef98a0bca8a76257b5d4 Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Thu, 16 May 2024 12:35:20 +0100 Subject: [PATCH 1/2] Use a real image in test_image_struct --- src/tests/resources/no_image.raw | Bin 0 -> 12288 bytes src/tests/test_image_struct.py | 22 ++++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 src/tests/resources/no_image.raw diff --git a/src/tests/resources/no_image.raw b/src/tests/resources/no_image.raw new file mode 100644 index 0000000000000000000000000000000000000000..b4a7514fb1c98e379ddae6ab2b371db76f676ad5 GIT binary patch literal 12288 zcmeH~(Uz+q3`K3N+S~vC;G2^G2}p3N?aWKET0sPMast>+Q&=bv3WNfoKqwFjgaV;J zC=d#S0)L>u?RLN2v&~eY?|h$)J?6)C^CG($kgYEE=8gKp>HBaTs3J9E!C&7s8k6`W z7$!>vYKQ!V3}eKY?~L)9R~mYj4?3*F-!=~@?dACye)3n~#sL%mRsdZ;^s(XRFiLr# zzw$8&nc+`L=r~{=j`(wDD4G&Y`6&aIKXSm}r<#8wliB(DW4;Jb@qGs@zUBjO9Psp) z{G0HX9^Z4I!VmeL{y*gR9jNg`{y6?w1z5ZBPdx`3e9d1Wzsxnt|8D=KA$9({i>Jlc zd_FyO{Vm-orYZ4@04aRkf6wRir0;|)mwBQcUis)LXzH{{Ee~tT%%4}JfDZiRa)}>v zkqO>7u*Vm^jKD;|ivtJwM`yfkP_kJ*V#kNe+ROXpE} z3J1Qzr+GQdbkTDl#hw~={1x)UBeCQ7Uu2q%M*np5aJcMI+py!CO#lzR$!BTEflB`r zcP>87*8`dJfbcKy@&AhTFMk+%`fr?TEWlC$91Xl9&c_dSHc_nbIWoEI-#D`Pa+mM& zcc&g2RQyZ&=h#s?@$c{~`LFSJc$4?*`Xgq<-r4^t_0B6Nqq#hv|08}U`i@_QpMFW{ z531Aq9~>87KT>{r?U%Rzh4XKWuN=6>mvx`7X8#YOuf!8=kY4i5qgr7cN kvE@p+G1Q3WNfoKqwFj{H6l`0mN!KF8}}l literal 0 HcmV?d00001 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(), } } From ae11b9bcbd69dafb2b9926ba0577636b291110c8 Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Thu, 16 May 2024 12:59:06 +0100 Subject: [PATCH 2/2] Fix RLE decompress with bitstring 4.1+ --- src/ttblit/core/compression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: