Add files via upload

This commit is contained in:
themixray 2021-11-03 22:12:56 +03:00 committed by GitHub
parent cf02d9af00
commit 6bd8352c50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,18 +27,15 @@ def save(surface, dest):
orig = surface._orig
_pg.image.save_extended(orig, dest)
def toBytes(surface):
def toString(surface):
try:
orig = surface._surface_orig
except:
orig = surface._orig
return _bz2.compress(
_p.dumps([
_pg.image.tostring(orig,"RGBA"),
list(surface.size)]))
return _bz2.compress(_p.dumps([_pg.image.tostring(orig,"RGBA"),list(surface.size)])).decode('latin1')
def fromBytes(string):
string = _p.loads(_bz2.decompress(string))
def fromString(string):
string = _p.loads(_bz2.decompress(string.encode('latin1')))
surf = _pg.image.fromstring(string[0],tuple(string[1]),"RGBA")
surface = _surface(tuple(string[1]))
surface.blit(surf,(0,0))