Add files via upload

This commit is contained in:
themixray 2021-11-04 14:25:51 +03:00 committed by GitHub
parent 0f185baf27
commit bc99b7875e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View file

@ -6,7 +6,7 @@ from pygwin.rect import rect
import pygwin.image as image
import pygwin.mixer as mixer
from pygame.locals import *
from pygwin.font import *
import pygwin.font as font
from pygwin._win import *
from pygwin._pg import pg
import pygwin.ui as ui

View file

@ -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))

View file

@ -242,6 +242,8 @@ class loadingBar(widget):
self.loaded = self.length
def reset(self):
self.loaded = 0
def get(self):
return self.loaded
def draw(self, win, pos):
self.surface = _s((self.width,self.height))
self.surface.fill(self.borderColor)