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.

44 lines
1.0 KiB

  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. # print 'returning image without resizing'
  21. return wx.StaticBitmap(parent, -1, wx.BitmapFromImage(image))
  22. # print 'returning resized image'
  23. ratio = float(_width) / _height
  24. image = image.Scale(target_height * ratio, target_height,
  25. wx.IMAGE_QUALITY_HIGH
  26. )
  27. return wx.StaticBitmap(parent, -1, wx.BitmapFromImage(image))
  28. def _GetTargetSize(size):
  29. width, height = size
  30. aspect_ratio = float(width) / height
  31. tHeight = 79
  32. tWidth = int(tHeight * aspect_ratio)
  33. return (tWidth, tHeight)
  34. if __name__ == '__main__':
  35. pass