- Bugfix with non-pil resizing.
This commit is contained in:
parent
57b5d00056
commit
1376f930fd
@ -58,22 +58,25 @@ class AttackDisplay(wx.ScrolledWindow):
|
|||||||
def update(self):
|
def update(self):
|
||||||
|
|
||||||
self.SetScrollbars(0,0,0,0,0,0)
|
self.SetScrollbars(0,0,0,0,0,0)
|
||||||
(sh,sw) = self.win.GetClientSizeTuple()
|
(sw,sh) = self.win.GetClientSizeTuple()
|
||||||
(W,H) = (sw,sh)
|
(W,H) = (sw,sh)
|
||||||
|
|
||||||
def makefit(H,W):
|
def makefit(W,H):
|
||||||
if self.win.fit:
|
if self.win.fit:
|
||||||
if W > sw:
|
# determine scaling factors for fitting
|
||||||
# correct width
|
wfactor = float(sw) / W
|
||||||
factor = float(sw) / W
|
hfactor = float(sh) / H
|
||||||
W = sw
|
|
||||||
H = H * factor
|
# select smallest factor (so it will fit)
|
||||||
if H > sh:
|
if hfactor < wfactor:
|
||||||
# correct height
|
factor = hfactor
|
||||||
factor = float(sh) / H
|
else:
|
||||||
H = sh
|
factor = wfactor
|
||||||
|
|
||||||
|
# apply scaling factor
|
||||||
W = W * factor
|
W = W * factor
|
||||||
return (int(H),int(W))
|
H = H * factor
|
||||||
|
return (int(W),int(H))
|
||||||
|
|
||||||
if self.attack.filetype == "png":
|
if self.attack.filetype == "png":
|
||||||
bmp = self.original
|
bmp = self.original
|
||||||
@ -82,16 +85,16 @@ class AttackDisplay(wx.ScrolledWindow):
|
|||||||
else:
|
else:
|
||||||
(W,H) = (bmp.GetWidth(), bmp.GetHeight())
|
(W,H) = (bmp.GetWidth(), bmp.GetHeight())
|
||||||
if self.win.fit:
|
if self.win.fit:
|
||||||
(H,W) = makefit(H,W)
|
(W,H) = makefit(W,H)
|
||||||
bmp = self.original.Scale(H,W)
|
bmp = self.original.Scale(W,H)
|
||||||
self.Image.SetBitmap(wx.BitmapFromImage(bmp))
|
self.Image.SetBitmap(wx.BitmapFromImage(bmp))
|
||||||
|
|
||||||
elif self.attack.filetype == "ps":
|
elif self.attack.filetype == "ps":
|
||||||
pil = self.original.copy()
|
pil = self.original.copy()
|
||||||
(H,W) = pil.size
|
(W,H) = pil.size
|
||||||
(H,W) = makefit(H,W)
|
(W,H) = makefit(W,H)
|
||||||
# we really only want antialias when it's smaller
|
# we really only want antialias when it's smaller
|
||||||
pil.thumbnail((H,W),Image.ANTIALIAS)
|
pil.thumbnail((W,H),Image.ANTIALIAS)
|
||||||
|
|
||||||
image = wx.EmptyImage(pil.size[0],pil.size[1])
|
image = wx.EmptyImage(pil.size[0],pil.size[1])
|
||||||
image.SetData(pil.convert('RGB').tostring())
|
image.SetData(pil.convert('RGB').tostring())
|
||||||
|
Loading…
Reference in New Issue
Block a user