From 0cbc79072dd661aad9fb764a04e6712d163126b5 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Thu, 29 Dec 2022 21:30:04 -0500 Subject: [PATCH] icon to rez --- icon.py | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 icon.py diff --git a/icon.py b/icon.py new file mode 100644 index 0000000..1ea8453 --- /dev/null +++ b/icon.py @@ -0,0 +1,153 @@ +# +# extract icons from an icon file. +# outputs rez +# +# See FTN $CA + +import sys +import getopt +import struct + + +class Icon: +# Icon: +# uint16_t IconType ($8000 = color, $0000 = b/w) +# uint16_t IconSize +# uint16_t IconHeight +# uint16_t IconWidth +# uint18_t IconImage[height * width / 2] +# uint18_t IconMask[height * width / 2] + + def __init__(self): + self.type = 0 + self.size = 0 + self.height = 0 + self.width = 0 + self.image = [] + self.mask = [] + + def unpack_from(self, buffer, offset): + x = struct.unpack_from("> 1 + + data = buffer[offset:offset+size] + self.image = [ data[x*width:(x+1)*width] for x in range(0, height)] + offset += size + + data = buffer[offset:offset+size] + self.mask = [ data[x*width:(x+1)*width] for x in range(0, height)] + offset += size + + return offset + +class IconData: + +# uint16_t iDataLen +# uint8_t iDataBoss[64] +# uint8_t iDataName[16] +# uint16_t iDataType +# uint16_t iDataAux +# Icon iDataBig +# Icon iDataSmall +# + + + def __init__(self): + self.len = 0 + self.boss = "" + self.name = "" + self.type = 0 + self.aux = 0 + self.big = None + self.small = None + + def unpack_from(self, buffer, offset): + + l, = struct.unpack_from("