Dear Radomir,

s = pygame.image.load("88keykbd.png")
f = StringIO.StringIO()
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


On Mon, Aug 11, 2014 at 12:21 AM, Radomir Dopieralski <pyg...@sheep.art.pl>
wrote:

> On 08/08/2014 11:16 AM, diliup gabadamudalige wrote:
> > Hi all!
> >
> > Is there a way to convert a pygame surface to a png or jpeg IN MEMORY
> > instead of saving to disk and loading again?
> > something like
> > get_screen = SCREEN.subsurface(0, 0, SCREENW, SCREENH) # grab the screen
> >
> > my_image = get_screen.convert(jpeg) # now convert the image to jpeg
> >
> > and now my_image is a jpeg image of get_screen
> >
> > I searched the net but couldn't find any other way other than save to
> > disk as jpeg and reload.
> >
> > Any positive OR negative help is very much appreciated.
>
> Sure, just use StringIO to use memory instead of a file.
>
> import pygame
> import StringIO
>
> s = pygame.image.load("yourimage.png")
> f = StringIO.StringIO()
> f.name = 'yourimage.jpg'
> pygame.image.save(s, f)
>
> yourimage = f.getvalue()
>
>
> --
> Radomir Dopieralski
>
>
>


-- 
Diliup Gabadamudalige

http://www.diliupg.com
http://soft.diliupg.com/

**********************************************************************************************
This e-mail is confidential. It may also be legally privileged. If you are
not the intended recipient or have received it in error, please delete it
and all copies from your system and notify the sender immediately by return
e-mail. Any unauthorized reading, reproducing, printing or further
dissemination of this e-mail or its contents is strictly prohibited and may
be unlawful. Internet communications cannot be guaranteed to be timely,
secure, error or virus-free. The sender does not accept liability for any
errors or omissions.
**********************************************************************************************

Reply via email to