Windows: Add "Save Screenshot" menu command

This commit is contained in:
kichikuou
2020-12-31 14:17:55 +09:00
parent 297ce20a83
commit 75cbb2bcef
5 changed files with 46 additions and 1 deletions
+19 -1
View File
@@ -517,7 +517,8 @@ void AGS::invalidate_screen(int sx, int sy, int width, int height)
dirty = true;
}
void AGS::update_screen() {
void AGS::update_screen()
{
if (!dirty)
return;
SDL_RenderClear(sdlRenderer);
@@ -526,6 +527,23 @@ void AGS::update_screen() {
dirty = false;
}
void AGS::save_screenshot(const char* path)
{
SDL_Surface* sf = SDL_CreateRGBSurface(0, 640, screen_height, 32, 0, 0, 0, 0);
SDL_Rect r = {0, 0, 640, screen_height};
SDL_UnlockSurface(hBmpDest);
SDL_BlitSurface(hBmpDest, &r, sf, NULL);
SDL_LockSurface(hBmpDest);
if (SDL_SaveBMP(sf, path) != 0) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "system3",
SDL_GetError(), g_window);
SDL_ClearError();
}
SDL_FreeSurface(sf);
}
#ifdef __EMSCRIPTEN__
extern "C" {