(self, array)
return sprite
Build sprite from bytearray in EGA modes.
Build sprite from bytearray in EGA modes.
Build sprite from bytearray in EGA modes .
def unpack(self, array):
        """Build sprite from bytearray in EGA modes."""
        width, height = struct.unpack('<HH', array[:4])
        row_bytes = (width + 7) // 8
        length = height * self._number_planes * row_bytes
        packed = array[4:4+length]
        # ensure iterations over memoryview yield int, not bytes, in Python 2
        packed = iterbytes(packed)
        # unpack all planes
        #bytes_to_interval
        allplanes = bytematrix.ByteMatrix.frompacked(
            packed, height=height*self._number_planes, items_per_byte=8
        )
        # clip to requested width
        allplanes = allplanes[:, :width]
        # de-interlace planes
        sprite_planes = (
            allplanes[_plane::self._number_planes, :] << _plane
            for _plane in range(self._number_planes)
        )
        # combine planes
        sprite = functools.reduce(operator.__ior__, sprite_planes)
        return sprite
def unpack ( self , array ) : width , height = struct . unpack ( '<HH' , array [ : 4 ] ) row_bytes = ( width + 7 ) // 8 length = height * self . _number_planes * row_bytes packed = array [ 4 : 4 + length ] # ensure iterations over memoryview yield int, not bytes, in Python 2 packed = iterbytes ( packed ) # unpack all planes #bytes_to_interval allplanes = bytematrix . ByteMatrix . frompacked ( packed , height = height * self . _number_planes , items_per_byte = 8 ) # clip to requested width allplanes = allplanes [ : , : width ] # de-interlace planes sprite_planes = ( allplanes [ _plane : : self . _number_planes , : ] << _plane for _plane in range ( self . _number_planes ) ) # combine planes sprite = functools . reduce ( operator . __ior__ , sprite_planes ) return sprite