Anybody know why this array I created from pygame's get_buffer method has the R, G, B, values reversed? I want to create an array with the colour values in the same order I put them in - like [8, 16, 32, 0]. Have I done something wrong or is this something with the way pygame stores pixel data?
>>> import pygame
>>> import pygame.gfxdraw
>>> import numpy as np
>>> background_colour = (1, 1, 1)
>>> width, height = (256, 256)
>>> screen = pygame.Surface((width, height))
>>> pygame.draw.rect(screen, (8, 16, 32), (0, 0, 100, 100), 0)
<rect(0, 0, 100, 100)>
>>> s = screen.get_buffer()
>>> x = np.fromstring(s.raw, dtype='b').reshape(height, width, 4)
>>> x[0, 0]
array([32, 16, 8, 0], dtype=int8)
I tried this but I loose the R value:
>>> y = x[:, :, 3:0:-1]
>>> y[0, 0]
array([ 0, 8, 16], dtype=int8)
(I'm using numpy version 1.8.2 so I don't have np.flip).