Add files via upload

This commit is contained in:
themixray 2021-11-03 21:02:39 +03:00 committed by GitHub
parent 47419536c1
commit cf02d9af00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ from pygwin._pg import pg as _pg
from pygwin.surface import surface as _surface
from PIL import Image as _im
import pickle as _p
import bz2 as _bz2
def load(path):
if path.endswith('.gif'):
@ -31,10 +32,13 @@ def toBytes(surface):
orig = surface._surface_orig
except:
orig = surface._orig
return _p.dumps([_pg.image.tostring(orig,"RGBA"),list(surface.size)])
return _bz2.compress(
_p.dumps([
_pg.image.tostring(orig,"RGBA"),
list(surface.size)]))
def fromBytes(string):
string = _p.loads(string)
string = _p.loads(_bz2.decompress(string))
surf = _pg.image.fromstring(string[0],tuple(string[1]),"RGBA")
surface = _surface(tuple(string[1]))
surface.blit(surf,(0,0))