, NumPy. NumPy uint8 s:
import numpy as np
fb = np.zeros((480, 640), dtype=np.uint8)
:
fb[:] = 0
Another big advantage is that you get a fast 2D array - you can do things like fb[80:120, 40:60]get a rectangular region cheaply and you can implement drawing operations like blitting with very little code. Also, with np.tobytesyou can still get a representation of the bytes.
source
share