[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pygame] fromstring() bug?
I think I've found a bug in pygame.image.fromstring().
I was using it to generate an embedded bitmap, and the colors turned out
wrong. I've reduced the code to the minimal example, which is attached.
The test code loads my color test bitmap, converts it to a string, then back
to an image. I have used the tostring() function successfully before, which
is why I think the problem is in fromstring().
I'm using pygame 1.2, with SDL 1.2.3 (from CVS, near 2001-Nov-5).
I haven't tried the latest pygame from CVS yet.
-Ray
#!/usr/bin/env python
import pygame, pygame.image
from pygame.locals import *
if __name__ == '__main__':
image = pygame.image.load("test.png")
size = image.get_size()
s = pygame.image.tostring(image, "RGBA")
image = pygame.image.fromstring(s, size, "RGBA")
size = image.get_size()
screen = pygame.display.set_mode(size)
screen.blit(image, (0,0))
pygame.display.flip()
done = 0
while not done:
event = pygame.event.wait()
if event.type in (QUIT, KEYDOWN):
done = 1
test.png