You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1 KiB

'''
Created on Jan 20, 2014
@author: Chris
'''
import wx
from PIL import Image # @UnresolvedImport
from app.images import image_store
def _load_image(image_path):
try:
return wx.Bitmap(image_path)
except:
raise IOError('Invalid Image path')
def _resize_bitmap(parent, _bitmap, target_height):
'''
Resizes a bitmap to a height of 89 pixels (the
size of the top panel), while keeping aspect ratio
in tact
'''
image = wx.ImageFromBitmap(_bitmap)
_width, _height = image.GetSize()
if _height < target_height:
print 'returning image without resizing'
return wx.StaticBitmap(parent, -1, wx.BitmapFromImage(image))
print 'returning resized image'
ratio = float(_width) / _height
image = image.Scale(target_height * ratio, target_height,
wx.IMAGE_QUALITY_HIGH
)
return wx.StaticBitmap(parent, -1, wx.BitmapFromImage(image))
def _GetTargetSize(size):
width, height = size
aspect_ratio = float(width)/height
tHeight = 79
tWidth = int(tHeight * aspect_ratio)
return (tWidth, tHeight)
if __name__ == '__main__':
pass