From d741bdc3753b33940198dee58d28173e2d49b60a Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Wed, 15 Jun 2016 00:27:07 -0700 Subject: [PATCH] VIDEO: Allow SCREENSHOT command to optionally specify bitmap file extension When PNG support is available, both .png and .bmp screenshots can be generated based on the file extension specified by the user on the SCREENSHOT command. If no extension is specified, then a PNG format screenshot will be produced. --- sim_video.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sim_video.c b/sim_video.c index 99d6b190..3dcd05ec 100644 --- a/sim_video.c +++ b/sim_video.c @@ -2146,10 +2146,16 @@ if (!filename) return SCPE_MEM; #if SDL_MAJOR_VERSION == 1 #if defined(HAVE_LIBPNG) -sprintf (fullname, "%s.png", filename); -stat = SDL_SavePNG(vid_image, fullname); +if (!match_ext (filename, "bmp")) { + sprintf (fullname, "%s%s", filename, match_ext (filename, "png") ? "" : ".png"); + stat = SDL_SavePNG(vid_image, fullname); + } +else { + sprintf (fullname, "%s", filename); + stat = SDL_SaveBMP(vid_image, fullname); + } #else -sprintf (fullname, "%s.bmp", filename); +sprintf (fullname, "%s%s", filename, match_ext (filename, "bmp") ? "" : ".bmp"); stat = SDL_SaveBMP(vid_image, fullname); #endif /* defined(HAVE_LIBPNG) */ #else /* SDL_MAJOR_VERSION != 1 */ @@ -2158,10 +2164,16 @@ if (1) { SDL_CreateRGBSurface(0, vid_width, vid_height, 32, 0x0000ff00, 0x000ff000, 0xff000000, 0x000000ff) ; SDL_RenderReadPixels(vid_renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch); #if defined(HAVE_LIBPNG) - sprintf (fullname, "%s.png", filename); - stat = SDL_SavePNG(sshot, fullname); + if (!match_ext (filename, "bmp")) { + sprintf (fullname, "%s%s", filename, match_ext (filename, "png") ? "" : ".png"); + stat = SDL_SavePNG(sshot, fullname); + } + else { + sprintf (fullname, "%s", filename); + stat = SDL_SaveBMP(sshot, fullname); + } #else - sprintf (fullname, "%s.bmp", filename); + sprintf (fullname, "%s%s", filename, match_ext (filename, "bmp") ? "" : ".bmp"); stat = SDL_SaveBMP(sshot, fullname); #endif /* defined(HAVE_LIBPNG) */ SDL_FreeSurface(sshot);