版权声明:本文可能为博主原创文章,若标明出处可随便转载。 https://blog.csdn.net/Jailman/article/details/78709134
裁剪坟墓
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))