Browse code

screenshot: one simple trick to reduce the file size

Sigrid Solveig Haflínudóttir authored on 29/06/2021 08:09:42
Showing 1 changed files
... ...
@@ -91,13 +91,13 @@ togglezoom(Uxn *u)
91 91
 static void
92 92
 screencapture(void)
93 93
 {
94
-	const Uint32 format = SDL_PIXELFORMAT_ARGB8888;
94
+	const Uint32 format = SDL_PIXELFORMAT_RGB24;
95 95
 	time_t t = time(NULL);
96 96
 	char fname[64];
97 97
 	int w, h;
98 98
 	SDL_Surface *surface;
99 99
 	SDL_GetRendererOutputSize(gRenderer, &w, &h);
100
-	surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, format);
100
+	surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 24, format);
101 101
 	SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch);
102 102
 	strftime(fname, sizeof(fname), "screenshot-%Y%m%d-%H%M%S.bmp", localtime(&t));
103 103
 	SDL_SaveBMP(surface, fname);