正确缩放SDL Surface而不裁剪的方法? [英] Proper way to scale an SDL Surface without clipping?

查看:436
本文介绍了正确缩放SDL Surface而不裁剪的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

缩放SDL表面的正确方法是什么?我在网上找到了一种解释,但它需要逐像素重新绘制Surface.似乎应该有某种方法可以通过SDL在本地进行此操作,而不是像这样重绘图像.在SDL文档中找不到涵盖此内容的任何内容.通过修改曲面的宽度和高度,我可以调整曲面的大小而没有任何问题,但是最终的曲面被剪切了.

what is the proper way to scale an SDL Surface? I found one explanation online but it required redrawing the Surface pixel by pixel. It seems like there should be some way of doing this natively through SDL rather than redrawing the image like that. I haven't been able to find anything in the SDL documentation that covers this. I am able to resize surfaces without any problem by modifying the surfaces width and height, but the resulting surface is clipped.

推荐答案

SDL不支持按比例缩放.根据 SDL_BlitSurface 的文档:

SDL doesn't support scaled blitting. According to the documentation of SDL_BlitSurface:

注意:SDL阻击器尚未(尚未) 有扩展能力 像它一样上下表面发白 其他更复杂的情况 发短信机制.你必须 如果自己想出一些办法 您想要缩放图像(例如使用 SDL_gfx).

Note: the SDL blitter does not (yet) have the capability of scaling the blitted surfaces up or down like it is the case with other more sophisticated blitting mechanisms. You have to figure something out for yourself if you want to scale images (e.g. use SDL_gfx).

您可以在此处找到SDL_gfx.编写自己的blitting函数还不错,这可能是一个有趣且有用的学习实验(尽管您会重新发明轮子).使用OpenGL也是一种选择,因为缩放和旋转等操作可以在单个函数调用中完成.

You could find SDL_gfx here. Writing your own blitting function isn't that bad, it might be a fun and useful learning experiment (though you'd be reinventing the wheel). Using OpenGL is also an option, as stuff like scaling and rotating could be done in a single function call.

这篇关于正确缩放SDL Surface而不裁剪的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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