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

Re: [pygame] image conversion in memory



I am reading up on creating and using zip files and may possibly use it,
What I am trying to do here is to hide the images on disk so that a user of the program will not be able to manipulate or change the images. What other way can you suggest?
Thanks for all the help so far.


On Wed, Aug 13, 2014 at 10:10 PM, Radomir Dopieralski <pygame@xxxxxxxxxxxx> wrote:
On 08/13/2014 04:35 PM, diliup gabadamudalige wrote:
> This is the complete and correct code. Can anyone say what;s wrong?
> Thanks in advance.
>
>
> import pygame
> import StringIO
>
> putimage = pygame.image.load("88keykbd.png")
> buff = StringIO.StringIO()
> buff.name <http://buff.name> = '88keykbd.png'
>
> pygame.image.save(putimage, buff)
>
> putimage = buff.getvalue()
> print "buff:", type(buff), "myimage:", type(putimage), "getimage:",
> type(putimage)
>
> print len(putimage)
> with open('myscrambledimage.dat', 'w') as newfile:
> Â Â newfile.write(putimage)
>
> with open('myscrambledimage.dat', 'r') as newfile:
> Â Â getimage= newfile.read()
> print len(getimage)

Open both files in binary mode, with 'wb' and 'rb' respectively.
Especially if you are on some funny operating system, like Windows.

Have you considered just putting all your images in a zip file, instead
of encoding them in strange ways?


--
The Sheep



--
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.
**********************************************************************************************