Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. TRUE = 1
  2. FALSE = 0
  3.  
  4. root=tk.Tk()
  5.  
  6. kimage_width = 512
  7. kimage_height = 512
  8. kimgSize = (kimage_width,kimage_height)
  9.  
  10. # Make a color 256K pixel photo of 'stuff', in bytes
  11. # The image data is in RGBX order
  12.  
  13. ColorImage=b''
  14.  
  15. for i in range (0,int(kimage_width * kimage_height/8)):
  16. ColorImage+=bytes([(i>>2) & 0xFF]) # Red
  17. ColorImage+=bytes([(i>>7) & 0xFF]) # Green
  18. ColorImage+=bytes([(i>>6) & 0xFF]) # Blue
  19. ColorImage+=bytes([(i>>0) & 0xFF]) # Not used
  20.  
  21. # copy it 8 times
  22.  
  23. ColorImage+=ColorImage+ColorImage+ColorImage # 4
  24. ColorImage+=ColorImage # total = 8 copies
  25.  
  26. # make a PIL image?
  27.  
  28. kimage = Image.frombytes('RGBX', kimgSize, ColorImage, 'raw')
  29.  
  30. kimage.show() # Display image
  31.  
  32. #######photo = base64.b64encode(ColorImage) # Crash - makes a zombie
  33.  
  34. b=tk.Button(root,justify = tk.LEFT)
  35. b.config(image=kimage, width="512", height="512")
  36. b.pack(side=tk.LEFT)
  37. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement