Add files via upload
This commit is contained in:
parent
47419536c1
commit
cf02d9af00
1 changed files with 6 additions and 2 deletions
|
@ -2,6 +2,7 @@ from pygwin._pg import pg as _pg
|
||||||
from pygwin.surface import surface as _surface
|
from pygwin.surface import surface as _surface
|
||||||
from PIL import Image as _im
|
from PIL import Image as _im
|
||||||
import pickle as _p
|
import pickle as _p
|
||||||
|
import bz2 as _bz2
|
||||||
|
|
||||||
def load(path):
|
def load(path):
|
||||||
if path.endswith('.gif'):
|
if path.endswith('.gif'):
|
||||||
|
@ -31,10 +32,13 @@ def toBytes(surface):
|
||||||
orig = surface._surface_orig
|
orig = surface._surface_orig
|
||||||
except:
|
except:
|
||||||
orig = surface._orig
|
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):
|
def fromBytes(string):
|
||||||
string = _p.loads(string)
|
string = _p.loads(_bz2.decompress(string))
|
||||||
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