transforming images in pygame

大憨熊 提交于 2019-12-22 06:59:38

问题


I'm trying to resize an image in pygame. I want my background image to fill the entire screen. I'd like to setup the entire screen based on the new (stretched) dimensions of the background. The following isn't working and I'm trying to figure out why.

Suggestions?

background = pygame.image.load("data/stars.bmp")
pygame.transform.scale(background, (1200,800))  #or some size x,y here.
bgRect = background.get_rect()
size = width, height = bgRect.width, bgRect.height
screen = pygame.display.set_mode(size)
screen.blit(background, bgRect)
pygame.display.flip()

回答1:


#pygame.transform.scale(background, (1200,800))  #or some size x,y here.
background = pygame.transform.scale(background, (1200,800))


来源:https://stackoverflow.com/questions/5228026/transforming-images-in-pygame

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!