[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] Problems with surfarrays



Hi,

I recently played around with per-pixel alpha and now tried to make a whole
image transparent while keeping its relative alpha values. So I came up with
this code:

       alphaarray=pygame.surfarray.array_alpha(self.surface)
       print alphaarray[15]
       temparray=alphaarray*color[3]/255
       alphaarray=temparray.astype(Int)
       print alphaarray[15]
       pygame.surfarray.blit_array(self.surface, alphaarray)
       print pygame.surfarray.array_alpha(self.surface)[15]

(the print statements were added later, and I know I could avoid the
temporary array, it's just for the sake of this demonstration)
Now look at the output:

[  0   0   0   0   0   0 255 255 255 255 255 255 255 255 223 191 191 191 191
      191 191   0   0   0   0   0 255 255 255   0   0   0   0   0   0   0]
[  0   0   0   0   0   0 150 150 150 150 150 150 150 150 131 112 112 112 112
      112 112   0   0   0   0   0 150 150 150   0   0   0   0   0   0   0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]

The second line looks like intended, but what happens then? If anybody could
shed some light on this I'd be grateful.

- Peter T


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org