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

Re: [pygame] Problem with surfarray on windows



Hi,

Here is a small example code.

If you remove the call to array_colorkey(...) or the set_colorkey(...) it
will draw a small rectangle in the middle of the screen. Otherwise it fails
with the message:

Traceback (most recent call last):
File "SurfarrayProblem.py", line 18, in ?
screen.blit(img, r)
pygame.error: Surfaces must not be locked during blit

<code>
import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((300, 300),1)

img = pygame.Surface([20,20])
img = img.convert()
img.set_colorkey((0xff, 0xff, 0xff), RLEACCEL)
img.fill((0,0,0))
r = img.get_rect()
r.centerx = 150
r.centery = 150
colorarray = pygame.surfarray.array_colorkey(img)
screen.fill((255,255,255))
screen.blit(img, r)
pygame.display.flip()

running = 1
while running:
for event in pygame.event.get():
if event.type == QUIT:
running = 0
</code>

>
> I haven't seen this bug before.
>
> Do you think you could make a little example?
>
> Then I should be able to test/debug it easier.
>
> Cheers,
>
>