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

Re: [pygame] image conversion in memory



On 08/11/2014 09:34 PM, diliup gabadamudalige wrote:
> Dear Radomir,
> 
> s = pygame.image.load("88keykbd.png")
> f = StringIO.StringIO()
> f.name <http://f.name> = '88keykbd.jpg'
> pygame.image.save(s, f)
> pygame.image.load("88keykbd.jpg")
> 
> 
> yourimage = f.getvalue()
> 
> why does the line pygame.image.load("88keykbd.jpg") throw an error? It
> throws pygame.error: Couldn't open 88keykbd.jpg
> I cant find the88keykbd.jpeg in the path

Of course you can't -- no such file exists. It's only in memory, in the
f variable. That's the whole point. You can get to the *contents* of
that variable with f.getvalue().

-- 
The Sheep