我正在SDL
和C
编写一个程序,我希望能够将窗口保存为图像。
这是我的代码:
screen = SDL_GetWindowSurface(win);
SDL_SaveBMP(screen,"screen");
但是当我执行它时,我得到了:
Segmentation Fault
从其他来源我收集它关于指针和内存访问。有什么帮助吗?
答案 0 :(得分:0)
SDL_Surface *sshot = SDL_CreateRGBSurface(0, 750, 750, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
SDL_RenderReadPixels(renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch);
SDL_SaveBMP(sshot, "screenshot.bmp");
SDL_FreeSurface(sshot);