screenshot: add timestampp to the filename
This commit is contained in:
parent
eb8c803b35
commit
66c16be3a5
|
@ -7,4 +7,4 @@
|
|||
*io.bit
|
||||
*.bak
|
||||
/*-test
|
||||
/screenshot.bmp
|
||||
/screenshot-*.bmp
|
||||
|
|
|
@ -92,14 +92,17 @@ static void
|
|||
screencapture(void)
|
||||
{
|
||||
const Uint32 format = SDL_PIXELFORMAT_ARGB8888;
|
||||
time_t t = time(NULL);
|
||||
char fname[64];
|
||||
int w, h;
|
||||
SDL_Surface *surface;
|
||||
SDL_GetRendererOutputSize(gRenderer, &w, &h);
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, format);
|
||||
SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch);
|
||||
SDL_SaveBMP(surface, "screenshot.bmp");
|
||||
strftime(fname, sizeof(fname), "screenshot-%Y%m%d-%H%M%S.bmp", localtime(&t));
|
||||
SDL_SaveBMP(surface, fname);
|
||||
SDL_FreeSurface(surface);
|
||||
fprintf(stderr, "Saved screenshot.bmp\n");
|
||||
fprintf(stderr, "Saved %s\n", fname);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue