裁剪坟墓
def cropimg(image, region): from cStringIO import StringIO img = Image.open(image) # region = (64, 0, 192, 95) cropImg = img.crop(region) imgBuf = StringIO(cropImg.tobytes()) imgx = pygame.image.frombuffer(imgBuf.getvalue(), (region[2] - region[0], region[3] - region[1]), "RGBA") return imgx img = r'resources/images/map.png' region = (161, 95, 193, 129) imgx = cropimg(img, region)
screen.blit(imgx, (200,200))