Why is there bit shifting when converting to an image from an array?
问题 I'm trying to create a QPixmap from a numpy array. The numpy array image is going to be 2D (ie no color info just grayscale). I'm trying to adapt this answer to my needs however I don't quite understand this line: b = (255 << 24 | a[:,:,0] << 16 | a[:,:,1] << 8 | a[:,:,2]).flatten() # pack RGB values There is some bitshifting going on and some bitwise or ' ing but I don't quite get it to be honest. So my dumbed down example is as follows: x, y = np.meshgrid(np.arange(1920), np.arange(1080),