有没有办法拉伸整个显示图像以适合给定的分辨率? [英] Is there a way to stretch the whole display image to fit a given resolution?

查看:104
本文介绍了有没有办法拉伸整个显示图像以适合给定的分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在使用pygame制作游戏,但遇到了一个小问题...

基本上,我希望能够将屏幕上的整个图像(我已经渗入它的所有东西)拉伸到用户调整窗口大小的分辨率.我在pygame和堆栈溢出文档中进行了很多搜索,但似乎找不到答案...这有可能吗?我游戏的源代码是很大的atm,如果有人需要,我会愿意发布它.抱歉,我的问题有点不清楚:)

I've been using pygame to make a game recently, and have ran into a little problem...

Basically, I would like to be able to stretch the whole image that is on the screen (all the things that I have blitted to it) into the resolution which the user has resized the window to. I've searched a lot on the documentation for pygame and on stack overflow and I can't seem to find an answer... Is it even possible? The source code for my game is pretty big atm, if anyone needs it I'll be willing to post it. Sorry if I made my question a little unclear :)

推荐答案

将所有内容拆分到单独的表面(而不是直接在屏幕上),我们称其为main_surface.然后将main_surface屏蔽到屏幕上. 用从VIDEORESIZE事件获得的新宽度和高度调用pygame.transform.scale(main_surface, (width, height),以将main_surface及其中的所有内容缩放到新的窗口尺寸.

Blit everything to a separate surface (not directly to the screen), let's call it main_surface. Then blit the main_surface to the screen. Call pygame.transform.scale(main_surface, (width, height) with the new width and height that you get from the VIDEORESIZE event to scale the main_surface and everything in it to the new window dimensions.

这篇关于有没有办法拉伸整个显示图像以适合给定的分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆