Advertisement
Guest User

Untitled

a guest
May 27th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1.         l__img = Image.open(i__content['files'][0])
  2.         l__size_available = self.m__bitmap.GetSize()
  3.         l__size_image = l__img.size
  4.         l__ratio_width = float(l__size_image[0]) / l__size_available[0]
  5.         l__ratio_height = float(l__size_image[1]) / l__size_available[1]
  6.         l__ratio_retained = int(math.ceil(max(l__ratio_width, l__ratio_height)))
  7.         l__size_new_image = (l__size_image[0]/l__ratio_retained, l__size_image[1]/l__ratio_retained)
  8.         l__img_tmp = l__img.resize(l__size_new_image)
  9.         l__img_tmp = l__img_tmp.convert('RGB')
  10.         l__img_data = StringIO.StringIO()
  11.         l__img_tmp.save(l__img_data, 'BMP')
  12.         l__img_data.seek(0)
  13.         l__image = wx.BitmapFromBuffer(l__size_new_image[0], l__size_new_image[1], l__img_data.read())
  14.         self.m__bitmap.SetBitmap(l__image)
  15.         self.m__panel.Refresh()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement