Add files via upload
This commit is contained in:
parent
0f185baf27
commit
bc99b7875e
3 changed files with 11 additions and 7 deletions
|
@ -16,8 +16,10 @@ def load(path):
|
|||
surfs.append(surf)
|
||||
return surfs
|
||||
else:
|
||||
surf = _surface(_im.open(path).size)
|
||||
surf.blit(_pg.image.load(path),(0,0))
|
||||
im = _im.open(path.encode('utf8').decode('utf8'))
|
||||
image = _pg.image.fromstring(im.tobytes(),im.size,im.mode)
|
||||
surf = _surface(im.size)
|
||||
surf.blit(image,(0,0))
|
||||
return surf
|
||||
|
||||
def save(surface, dest):
|
||||
|
@ -27,15 +29,15 @@ def save(surface, dest):
|
|||
orig = surface._orig
|
||||
_pg.image.save_extended(orig, dest)
|
||||
|
||||
def toString(surface):
|
||||
def toBytes(surface):
|
||||
try:
|
||||
orig = surface._surface_orig
|
||||
except:
|
||||
orig = surface._orig
|
||||
return _bz2.compress(_p.dumps([_pg.image.tostring(orig,"RGBA"),list(surface.size)])).decode('latin1')
|
||||
return _bz2.compress(_p.dumps([_pg.image.tostring(orig,"RGBA"),list(surface.size)]))
|
||||
|
||||
def fromString(string):
|
||||
string = _p.loads(_bz2.decompress(string.encode('latin1')))
|
||||
def fromBytes(bytes):
|
||||
string = _p.loads(_bz2.decompress(bytes))
|
||||
surf = _pg.image.fromstring(string[0],tuple(string[1]),"RGBA")
|
||||
surface = _surface(tuple(string[1]))
|
||||
surface.blit(surf,(0,0))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue