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.

33 lines
777 B

  1. '''
  2. Created on Jan 20, 2014
  3. @author: Chris
  4. '''
  5. import wx
  6. def _load_image(image_path):
  7. try:
  8. return wx.Bitmap(image_path)
  9. except:
  10. raise IOError('Invalid Image path')
  11. def resize_bitmap(parent, _bitmap, target_height):
  12. '''
  13. Resizes a bitmap to a height of 89 pixels (the
  14. size of the top panel), while keeping aspect ratio
  15. in tact
  16. '''
  17. image = wx.ImageFromBitmap(_bitmap)
  18. _width, _height = image.GetSize()
  19. if _height < target_height:
  20. return wx.StaticBitmap(parent, -1, wx.BitmapFromImage(image))
  21. ratio = float(_width) / _height
  22. image = image.Scale(target_height * ratio, target_height, wx.IMAGE_QUALITY_HIGH)
  23. return wx.StaticBitmap(parent, -1, wx.BitmapFromImage(image))
  24. if __name__ == '__main__':
  25. pass