1
0
mirror of https://github.com/simh/simh.git synced 2026-01-11 23:52:58 +00:00

VIDEO: handle error conditions and uninitialized displays when taking a screenshot.

This commit is contained in:
Sergey Svishchev 2025-09-28 16:23:22 +03:00 committed by Mark Pizzolato
parent b838d94282
commit bcdc992cca

View File

@ -2681,7 +2681,14 @@ if (!fullname)
if (1) {
SDL_Surface *sshot = sim_end ? SDL_CreateRGBSurface(0, vptr->vid_width, vptr->vid_height, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000) :
SDL_CreateRGBSurface(0, vptr->vid_width, vptr->vid_height, 32, 0x0000ff00, 0x000ff000, 0xff000000, 0x000000ff) ;
SDL_RenderReadPixels(vptr->vid_renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch);
if (sshot == NULL)
return SCPE_MEM;
if (SDL_RenderReadPixels(vptr->vid_renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch) != 0) {
SDL_FreeSurface(sshot);
sim_printf ("Error creating screenshot: %s\n", SDL_GetError());
return SCPE_ARG | SCPE_NOMESSAGE;
}
if (sim_libpng_available) {
if (!match_ext (filename, "bmp")) {
sprintf (fullname, "%s%s", filename, match_ext (filename, "png") ? "" : ".png");
@ -2732,6 +2739,8 @@ else {
}
strncpy (name, _screenshot_filename, n);
for (vptr = &vid_first; vptr != NULL; vptr = vptr->next) {
if (vptr->vid_width == 0)
continue;
if (vid_active > 1)
sprintf (name + n, "%d%s", i++, extension);
else