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

SV: Re: [pygame] Problem with surfarray on windows



Wow, really quick response!
Thanks!

Best Regards
/John

---------  Ursprungligt Meddelande --------
Från: pygame-users@xxxxxxxx
Till: pygame-users@xxxxxxxx <pygame-users@xxxxxxxx>
Ämne: Re: [pygame] Problem with surfarray on windows
Datum: 2005/09/08 09:44

>
> Hey,
>
> thanks for the example :)
>
>
> Unforunately there was a bug where it locked the surface again at the
> end of the function, instead of unlocking it.
>
> Which is fixed in cvs.  So the it will be fixed in the next release.
>
> For now, as a work around you can unlock it twice afterward.
> img.unlock()
> img.unlock()
>
>
> Cheers.
>
>
> On 9/8/05, John Eriksson &lt;john@xxxxxxxxxxxx&gt; wrote:
> &gt; Hi,
> &gt;
> &gt; Here is a small example code.
> &gt;
> &gt; If you remove the call to array_colorkey(...) or the
set_colorkey(...) it&gt; will draw a small rectangle in the middle of the
screen. Otherwise it fails
> &gt; with the message:
> &gt;
> &gt; Traceback (most recent call last):
> &gt; File &quot;SurfarrayProblem.py&quot;, line 18, in ?
> &gt; screen.blit(img, r)
> &gt; pygame.error: Surfaces must not be locked during blit
> &gt;
> &gt; &lt;code&gt;
> &gt; import pygame
> &gt; from pygame.locals import *
> &gt;
> &gt; pygame.init()
> &gt; screen = pygame.display.set_mode((300, 300),1)
> &gt;
> &gt; img = pygame.Surface([20,20])
> &gt; img = img.convert()
> &gt; img.set_colorkey((0xff, 0xff, 0xff), RLEACCEL)
> &gt; img.fill((0,0,0))
> &gt; r = img.get_rect()
> &gt; r.centerx = 150
> &gt; r.centery = 150
> &gt; colorarray = pygame.surfarray.array_colorkey(img)
> &gt; screen.fill((255,255,255))
> &gt; screen.blit(img, r)
> &gt; pygame.display.flip()
> &gt;
> &gt; running = 1
> &gt; while running:
> &gt; for event in pygame.event.get():
> &gt; if event.type = QUIT:
> &gt; running = 0
> &gt; &lt;/code&gt;
> &gt;
> &gt; &gt;
> &gt; &gt; I haven't seen this bug before.
> &gt; &gt;
> &gt; &gt; Do you think you could make a little example?
> &gt; &gt;
> &gt; &gt; Then I should be able to test/debug it easier.
> &gt; &gt;
> &gt; &gt; Cheers,
> &gt; &gt;
> &gt; &gt;
> &gt;
> &gt;
>
>
>
>