[Image-SIG] loading PIL image to pygame without the need to write atemporary image file
Fredrik Lundh
fredrik at pythonware.com
Sat May 7 14:41:01 CEST 2005
Jelle Feringa wrote:
> My guess was that pilmage.tostring() would be quite similar to pygame's
> pygame.image.tostring(img, "RGB") function. That unfortuanately isn't the
> case.
judging from the pygame documentation, they do the exact same thing
(but with slightly different arguments). according to the documentation,
the following should work:
mode = image.mode
size = image.size
data = image.tostring()
assert mode in "RGB", "RGBA"
surface = pygame.image.fromstring(data, size, mode)
(and you could probably use frombuffer instead of fromstring).
> When I use the PIL function to encode to a string, the program crashes after
> a couple of frames, and works fine with the pygame string function.
it crashes and works fine? how does it crash? traceback? coredump?
what crashes and what works?
</F>
More information about the Image-SIG
mailing list