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

2 years ago
  1. '''
  2. Utilities for loading, resizing and converting between PIL and WX image formats
  3. '''
  4. import six
  5. from PIL import Image # type: ignore
  6. import wx # type: ignore
  7. from gooey.gui.three_to_four import bitmapFromBufferRGBA
  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 = bitmapFromBufferRGBA(im, rgba)
  19. return wx.StaticBitmap(parent, bitmap=bitmapData)
  20. if __name__ == '__main__':
  21. pass