From cf02d9af007e6face96c31264c883618b17e1883 Mon Sep 17 00:00:00 2001 From: themixray <35273590+themixray@users.noreply.github.com> Date: Wed, 3 Nov 2021 21:02:39 +0300 Subject: [PATCH] Add files via upload --- pygwin/image.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pygwin/image.py b/pygwin/image.py index 358b99f..0a8a759 100644 --- a/pygwin/image.py +++ b/pygwin/image.py @@ -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))