From 6bd8352c5096ed2c281a6c26486ca8942932b02e Mon Sep 17 00:00:00 2001 From: themixray <35273590+themixray@users.noreply.github.com> Date: Wed, 3 Nov 2021 22:12:56 +0300 Subject: [PATCH] Add files via upload --- pygwin/image.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pygwin/image.py b/pygwin/image.py index 0a8a759..be2aa6a 100644 --- a/pygwin/image.py +++ b/pygwin/image.py @@ -27,18 +27,15 @@ def save(surface, dest): orig = surface._orig _pg.image.save_extended(orig, dest) -def toBytes(surface): +def toString(surface): try: orig = surface._surface_orig except: orig = surface._orig - return _bz2.compress( - _p.dumps([ - _pg.image.tostring(orig,"RGBA"), - list(surface.size)])) + return _bz2.compress(_p.dumps([_pg.image.tostring(orig,"RGBA"),list(surface.size)])).decode('latin1') -def fromBytes(string): - string = _p.loads(_bz2.decompress(string)) +def fromString(string): + string = _p.loads(_bz2.decompress(string.encode('latin1'))) surf = _pg.image.fromstring(string[0],tuple(string[1]),"RGBA") surface = _surface(tuple(string[1])) surface.blit(surf,(0,0))