Add files via upload
This commit is contained in:
parent
cf02d9af00
commit
6bd8352c50
1 changed files with 4 additions and 7 deletions
|
@ -27,18 +27,15 @@ def save(surface, dest):
|
||||||
orig = surface._orig
|
orig = surface._orig
|
||||||
_pg.image.save_extended(orig, dest)
|
_pg.image.save_extended(orig, dest)
|
||||||
|
|
||||||
def toBytes(surface):
|
def toString(surface):
|
||||||
try:
|
try:
|
||||||
orig = surface._surface_orig
|
orig = surface._surface_orig
|
||||||
except:
|
except:
|
||||||
orig = surface._orig
|
orig = surface._orig
|
||||||
return _bz2.compress(
|
return _bz2.compress(_p.dumps([_pg.image.tostring(orig,"RGBA"),list(surface.size)])).decode('latin1')
|
||||||
_p.dumps([
|
|
||||||
_pg.image.tostring(orig,"RGBA"),
|
|
||||||
list(surface.size)]))
|
|
||||||
|
|
||||||
def fromBytes(string):
|
def fromString(string):
|
||||||
string = _p.loads(_bz2.decompress(string))
|
string = _p.loads(_bz2.decompress(string.encode('latin1')))
|
||||||
surf = _pg.image.fromstring(string[0],tuple(string[1]),"RGBA")
|
surf = _pg.image.fromstring(string[0],tuple(string[1]),"RGBA")
|
||||||
surface = _surface(tuple(string[1]))
|
surface = _surface(tuple(string[1]))
|
||||||
surface.blit(surf,(0,0))
|
surface.blit(surf,(0,0))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue