How to take screenshot of certain part of screen in Pygame

后端 未结 4 1397
感动是毒
感动是毒 2021-01-04 23:26

Is there a way I can take a screenshot of the right half of my pygame window?

I\'m making a game using pygame and I need to take a snapshot of the screen but not the

4条回答
  •  一生所求
    2021-01-05 00:11

    This didn't exactly work on my system with Python 3.7.4. Here is a version which worked:

    rect = pygame.Rect(25, 25, 100, 50)
    sub = screen.subsurface(rect)
    screenshot = pygame.Surface((100, 50))
    screenshot.blit(sub, (0,0))
    pygame.image.save(screenshot, "screenshot.jpg")
    

提交回复
热议问题