capture_screen: check for errors
This commit is contained in:
parent
ff6d9e39ca
commit
05356e23b1
10
src/uxnemu.c
10
src/uxnemu.c
|
@ -289,13 +289,15 @@ capture_screen(void)
|
||||||
int w, h;
|
int w, h;
|
||||||
SDL_Surface *surface;
|
SDL_Surface *surface;
|
||||||
SDL_GetRendererOutputSize(emu_renderer, &w, &h);
|
SDL_GetRendererOutputSize(emu_renderer, &w, &h);
|
||||||
surface = SDL_CreateRGBSurface(0, w, h, 24, Rmask, Gmask, Bmask, 0);
|
if((surface = SDL_CreateRGBSurface(0, w, h, 24, Rmask, Gmask, Bmask, 0)) == NULL)
|
||||||
|
return;
|
||||||
SDL_RenderReadPixels(emu_renderer, NULL, format, surface->pixels, surface->pitch);
|
SDL_RenderReadPixels(emu_renderer, NULL, format, surface->pixels, surface->pitch);
|
||||||
strftime(fname, sizeof(fname), "screenshot-%Y%m%d-%H%M%S.bmp", localtime(&t));
|
strftime(fname, sizeof(fname), "screenshot-%Y%m%d-%H%M%S.bmp", localtime(&t));
|
||||||
SDL_SaveBMP(surface, fname);
|
if(SDL_SaveBMP(surface, fname) == 0){
|
||||||
|
fprintf(stderr, "Saved %s\n", fname);
|
||||||
|
fflush(stderr);
|
||||||
|
}
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
fprintf(stderr, "Saved %s\n", fname);
|
|
||||||
fflush(stderr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue