(self, array)
return sprite
Unpack bytearray into sprite.
Unpack bytearray into sprite.
Unpack bytearray into sprite .
def unpack(self, array):
        """Unpack bytearray into sprite."""
        row_bits, height = struct.unpack('<HH', array[0:4])
        width = row_bits // self._bitsperpixel
        row_bytes = (width * self._bitsperpixel + 7) // 8
        byte_size = row_bytes * height
        # bytes_to_interval
        packed = array[4:4+byte_size]
        # ensure iterations over memoryview yield int, not bytes, in Python 2
        # frompacked can't take interators, would need a width argument
        #packed = iterbytes(packed)
        if PY2:
            packed = bytearray(packed)
        sprite = bytematrix.ByteMatrix.frompacked(
            packed, height, items_per_byte=8 // self._bitsperpixel
        )
        # clip to requested width
        sprite = sprite[:, :width]
        return sprite
def unpack ( self , array ) : row_bits , height = struct . unpack ( '<HH' , array [ 0 : 4 ] ) width = row_bits // self . _bitsperpixel row_bytes = ( width * self . _bitsperpixel + 7 ) // 8 byte_size = row_bytes * height # bytes_to_interval packed = array [ 4 : 4 + byte_size ] # ensure iterations over memoryview yield int, not bytes, in Python 2 # frompacked can't take interators, would need a width argument #packed = iterbytes(packed) if PY2 : packed = bytearray ( packed ) sprite = bytematrix . ByteMatrix . frompacked ( packed , height , items_per_byte = 8 // self . _bitsperpixel ) # clip to requested width sprite = sprite [ : , : width ] return sprite