Add files via upload
This commit is contained in:
parent
0f185baf27
commit
bc99b7875e
3 changed files with 11 additions and 7 deletions
|
@ -6,7 +6,7 @@ from pygwin.rect import rect
|
||||||
import pygwin.image as image
|
import pygwin.image as image
|
||||||
import pygwin.mixer as mixer
|
import pygwin.mixer as mixer
|
||||||
from pygame.locals import *
|
from pygame.locals import *
|
||||||
from pygwin.font import *
|
import pygwin.font as font
|
||||||
from pygwin._win import *
|
from pygwin._win import *
|
||||||
from pygwin._pg import pg
|
from pygwin._pg import pg
|
||||||
import pygwin.ui as ui
|
import pygwin.ui as ui
|
||||||
|
|
|
@ -16,8 +16,10 @@ def load(path):
|
||||||
surfs.append(surf)
|
surfs.append(surf)
|
||||||
return surfs
|
return surfs
|
||||||
else:
|
else:
|
||||||
surf = _surface(_im.open(path).size)
|
im = _im.open(path.encode('utf8').decode('utf8'))
|
||||||
surf.blit(_pg.image.load(path),(0,0))
|
image = _pg.image.fromstring(im.tobytes(),im.size,im.mode)
|
||||||
|
surf = _surface(im.size)
|
||||||
|
surf.blit(image,(0,0))
|
||||||
return surf
|
return surf
|
||||||
|
|
||||||
def save(surface, dest):
|
def save(surface, dest):
|
||||||
|
@ -27,15 +29,15 @@ def save(surface, dest):
|
||||||
orig = surface._orig
|
orig = surface._orig
|
||||||
_pg.image.save_extended(orig, dest)
|
_pg.image.save_extended(orig, dest)
|
||||||
|
|
||||||
def toString(surface):
|
def toBytes(surface):
|
||||||
try:
|
try:
|
||||||
orig = surface._surface_orig
|
orig = surface._surface_orig
|
||||||
except:
|
except:
|
||||||
orig = surface._orig
|
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):
|
def fromBytes(bytes):
|
||||||
string = _p.loads(_bz2.decompress(string.encode('latin1')))
|
string = _p.loads(_bz2.decompress(bytes))
|
||||||
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))
|
||||||
|
|
|
@ -242,6 +242,8 @@ class loadingBar(widget):
|
||||||
self.loaded = self.length
|
self.loaded = self.length
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.loaded = 0
|
self.loaded = 0
|
||||||
|
def get(self):
|
||||||
|
return self.loaded
|
||||||
def draw(self, win, pos):
|
def draw(self, win, pos):
|
||||||
self.surface = _s((self.width,self.height))
|
self.surface = _s((self.width,self.height))
|
||||||
self.surface.fill(self.borderColor)
|
self.surface.fill(self.borderColor)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue