SDL 将窗口另存为 BMP [英] SDL Saving window as BMP

查看:25
本文介绍了SDL 将窗口另存为 BMP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 SDLC 编写程序,我希望能够将窗口保存为图像.

I am writing a program in SDL and C and I want to be able to save the window as an image.

这是我的代码:

screen = SDL_GetWindowSurface(win);
SDL_SaveBMP(screen,"screen");

但是当我执行它时,我得到:

But when I execute it I get:

Segmentation Fault

我从其他来源收集到关于指针和内存访问的信息.有什么帮助吗?

From other sources I gather that its about pointers and memory access. Any help?

推荐答案

在窗口表面调用 SDL_LockSurface在保存位图之前,然后是 SDL_UnlockSurface.

Call SDL_LockSurface on a window surface before saving bitmap, and SDL_UnlockSurface after that.

这篇关于SDL 将窗口另存为 BMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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