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

Re: [pygame] pygame.image.frombuffer problems



On Thu, 2005-12-29 at 18:03 -0600, Trevor Fancher wrote:
> I am having some problems with the pygame.image.frombuffer function.   
> I have
> also tried pygame.image.fromstring in the same place.


> buf = StringIO.StringIO()
> s.write_to_png(buf)

> size = (s.get_width(), s.get_height())
> image = pygame.image.frombuffer(buf.getvalue(), size, 'ARGB').convert()
> image.set_colorkey((0, 0, 0))


The problem is that you are writing a compressed PNG data file into the
buffer. The pygame 'fromstring' and 'frombuffer' functions expeect a
string with raw pixel data.

I've lurked on the cairo list every once in awhile, I'm pretty sure
there is a way to get this type of string from the cairo surface.