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
712 B

  1. '''
  2. Utilities for loading, resizing and converting between PIL and WX image formats
  3. '''
  4. import six
  5. from PIL import Image
  6. import wx
  7. from gooey.gui.three_to_four import imageFromBitmap, bitmapFromImage
  8. def loadImage(img_path):
  9. return Image.open(img_path)
  10. def resizeImage(im, targetHeight):
  11. im.thumbnail((six.MAXSIZE, targetHeight))
  12. return im
  13. def wrapBitmap(im, parent):
  14. try:
  15. rgba = im.convert('RGBA').tobytes()
  16. except AttributeError:
  17. rgba = im.convert('RGBA').tostring()
  18. bitmapData = wx.Bitmap.FromBufferRGBA(im.size[0], im.size[1], rgba)
  19. return wx.StaticBitmap(parent, bitmap=bitmapData)
  20. if __name__ == '__main__':
  21. pass