Skip to content

Instantly share code, notes, and snippets.

@Andygmb
Created January 9, 2015 00:19
Show Gist options
  • Save Andygmb/d40e07d5b9f57cfd4808 to your computer and use it in GitHub Desktop.
Save Andygmb/d40e07d5b9f57cfd4808 to your computer and use it in GitHub Desktop.
import pygame
import cStringIO
from PIL import Image, ImageGrab
w = 345
h = 170
x, x1 = 1575, 1920
y, y1 = 910, 1080
resize = (1000, 800)
pygame.init()
screengrab = ImageGrab.grab(bbox=(x, y, x1, y1)).resize(resize)
tmp = cStringIO.StringIO()
screengrab.save(tmp, "bmp")
img = tmp.getvalue()
background = pygame.image.load(img)
Traceback (most recent call last):
File "C:\Users\Andrew\Desktop\Age2MaxiMapper.py", line 19, in <module>
background = pygame.image.load(img)
TypeError: must be string without null bytes, not str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment