Add files via upload

This commit is contained in:
themixray 2021-11-02 19:52:29 +03:00 committed by GitHub
parent cdadd9af36
commit 0b94717fb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 88 additions and 228 deletions

View file

@ -20,23 +20,23 @@ def load(path):
surf._surface_orig = image
return surf
def save(surface, path):
def save(surface, dest):
if type(surface) == _surface:
orig = surface._surface_orig
else:
orig = surface._orig
_pg.image.save_extended(orig, path)
_pg.image.save_extended(orig, dest)
def toString(surface):
if type(surface) == _surface:
orig = surface._surface_orig
else:
orig = surface._orig
return _p.dumps([_pg.image.tostring(orig, "RGBA"), list(surface.size)])
return _p.dumps([_pg.image.tostring(orig,"RGBA"),list(surface.size)],0)
def fromString(string):
string = _p.loads(string)
surf = _pg.image.fromstring(string[0], tuple(string[1]), "RGBA")
string = _p.loads(string, encoding='latin1')
surf = _pg.image.fromstring(string[0],tuple(string[1]),"RGBA")
surface = _surface(tuple(string[1]))
surface._surface_orig = surf
return surface