[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Surfarray Question



Hi Ian,

The array2d values are raw pixel values. They are surface specific. This will select out a single color for a 24 or 32 bit surface:

red_shift = surf.get_shifts()[0]                 # For receding objects
red_mask = surf.get_masks()[0]
reds = (array & red_mask) >> red_shift

But array3d already does this for you.

Lenard


Ian Mallett wrote:
Hello,

How are the values in a pygame.surfarray.array2d() array formed? I would like to convert a value from the array into a single channel value in the range [0,255]. (Assume 3 channels of equal intensity, so greyscale).

Ian