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.

36 lines
882 B

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