def parse_rectangle(cls, client, x, y, width, height, data):
split = width * height * client.framebuffer.bypp
image = np.frombuffer(data[:split], np.uint8).reshape((height, width, 4))[:, :, [0, 1, 2]]
# Turn raw bytes into uint8 array
mask = np.frombuffer(data[split:], np.uint8)
# Turn uint8 array into bit array, and go over the scanlines
mask = np.unpackbits(mask).reshape((height, -1 if mask.size else 0))[:, :width]
encoding = cls(image, mask)
return Rectangle(x, y, width, height, encoding)
评论列表
文章目录