(self, sprite)
return size_record + interlaced
Pack the sprite into bytearray.
Pack the sprite into bytearray.
Pack the sprite into bytearray .
def pack(self, sprite):
        """Pack the sprite into bytearray."""
        # extract colour planes
        # note that to get the plane this should be bit-masked - (s >> _p) & 1
        # but bytematrix.packbytes will do this for us
        sprite_planes = (
            (sprite >> _plane)  # & 1
            for _plane in range(self._number_planes)
        )
        # pack the bits into bytes
        #interval_to_bytes
        packed_planes = list(
            _sprite.packed(items_per_byte=8)
            for _sprite in sprite_planes
        )
        # interlace row-by-row
        row_bytes = (sprite.width + 7) // 8
        length = sprite.height * self._number_planes * row_bytes
        interlaced = bytearray().join(
            _packed[_row_offs : _row_offs+row_bytes]
            for _row_offs in range(0, length, row_bytes)
            for _packed in packed_planes
        )
        size_record = struct.pack('<HH', sprite.width, sprite.height)
        return size_record + interlaced
def pack ( self , sprite ) : # extract colour planes # note that to get the plane this should be bit-masked - (s >> _p) & 1 # but bytematrix.packbytes will do this for us sprite_planes = ( ( sprite >> _plane ) # & 1 for _plane in range ( self . _number_planes ) ) # pack the bits into bytes #interval_to_bytes packed_planes = list ( _sprite . packed ( items_per_byte = 8 ) for _sprite in sprite_planes ) # interlace row-by-row row_bytes = ( sprite . width + 7 ) // 8 length = sprite . height * self . _number_planes * row_bytes interlaced = bytearray ( ) . join ( _packed [ _row_offs : _row_offs + row_bytes ] for _row_offs in range ( 0 , length , row_bytes ) for _packed in packed_planes ) size_record = struct . pack ( '<HH' , sprite . width , sprite . height ) return size_record + interlaced