/* SCR_RSShot_f */ void SCR_RSShot_f (void) { int x, y; unsigned char *src, *dest; char pcxname[80]; unsigned char *newbuf; int w, h; int dx, dy, dex, dey, nx; int r, b, g; int count; float fracw, frach; char st[80]; time_t now; if (CL_IsUploading ()) return; // already one pending if (cls.state < ca_onserver) return; // gotta be connected Con_Printf ("Remote screen shot requested.\n"); snprintf (pcxname, sizeof (pcxname), "rss.pcx"); // // save the pcx file // D_EnableBackBufferAccess (); // enable direct drawing of console // to back // buffer w = (vid.width < RSSHOT_WIDTH) ? vid.width : RSSHOT_WIDTH; h = (vid.height < RSSHOT_HEIGHT) ? vid.height : RSSHOT_HEIGHT; fracw = (float) vid.width / (float) w; frach = (float) vid.height / (float) h; newbuf = calloc (1, w * h); for (y = 0; y < h; y++) { dest = newbuf + (w * y); for (x = 0; x < w; x++) { r = g = b = 0; dx = x * fracw; dex = (x + 1) * fracw; if (dex == dx) dex++; // at least one dy = y * frach; dey = (y + 1) * frach; if (dey == dy) dey++; // at least one count = 0; for ( /* */ ; dy < dey; dy++) { src = vid.buffer + (vid.rowbytes * dy) + dx; for (nx = dx; nx < dex; nx++) { r += host_basepal[*src * 3]; g += host_basepal[*src * 3 + 1]; b += host_basepal[*src * 3 + 2]; src++; count++; } } r /= count; g /= count; b /= count; *dest++ = MipColor (r, g, b); } } time (&now); strcpy (st, ctime (&now)); st[strlen (st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - strlen (st) * 8, 0, w); strncpy (st, cls.servername, sizeof (st)); st[sizeof (st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - strlen (st) * 8, 10, w); strncpy (st, name->string, sizeof (st)); st[sizeof (st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - strlen (st) * 8, 20, w); WritePCXfile (pcxname, newbuf, w, h, w, host_basepal, true, false); free (newbuf); D_DisableBackBufferAccess (); // for adapters that can't stay // mapped in // for linear writes all the time Con_Printf ("Wrote %s\n", pcxname); Con_Printf ("Sending shot to server...\n"); }
/* ================== SCR_RSShot_f ================== */ void SCR_RSShot_f (void) { int x, y; unsigned char *src, *dest; char pcxname[80]; #if 0 int i; char checkname[MAX_OSPATH]; #endif unsigned char *newbuf; //, *srcbuf; // int srcrowbytes; int w, h; int dx, dy, dex, dey, nx; int r, b, g; int count; float fracw, frach; char st[80]; time_t now; if (CL_IsUploading()) return; // already one pending if (cls.state < ca_onserver) return; // gotta be connected if (!scr_allowsnap.value) { MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, "snap\n"); Con_Printf("Refusing remote screen shot request.\n"); return; } Con_Printf("Remote screen shot requested.\n"); #if 0 // // find a file name to save it to // strcpy(pcxname,"mquake00.pcx"); for (i=0 ; i<=99 ; i++) { pcxname[6] = i/10 + '0'; pcxname[7] = i%10 + '0'; #if defined (__APPLE__) || defined (MACOSX) snprintf (checkname, MAX_OSPATH, "%s/%s", com_gamedir, pcxname); #else sprintf (checkname, "%s/%s", com_gamedir, pcxname); #endif /* __APPLE__ || MACOSX */ if (Sys_FileTime(checkname) == -1) break; // file doesn't exist } if (i==100) { Con_Printf ("SCR_ScreenShot_f: Couldn't create a PCX"); return; } #endif // // save the pcx file // D_EnableBackBufferAccess (); // enable direct drawing of console to back // buffer w = (vid.width < RSSHOT_WIDTH) ? vid.width : RSSHOT_WIDTH; h = (vid.height < RSSHOT_HEIGHT) ? vid.height : RSSHOT_HEIGHT; fracw = (float)vid.width / (float)w; frach = (float)vid.height / (float)h; newbuf = malloc(w*h); for (y = 0; y < h; y++) { dest = newbuf + (w * y); for (x = 0; x < w; x++) { r = g = b = 0; dx = x * fracw; dex = (x + 1) * fracw; if (dex == dx) dex++; // at least one dy = y * frach; dey = (y + 1) * frach; if (dey == dy) dey++; // at least one count = 0; for (/* */; dy < dey; dy++) { src = vid.buffer + (vid.rowbytes * dy) + dx; for (nx = dx; nx < dex; nx++) { r += host_basepal[*src * 3]; g += host_basepal[*src * 3+1]; b += host_basepal[*src * 3+2]; src++; count++; } } r /= count; g /= count; b /= count; *dest++ = MipColor(r, g, b); } } time(&now); strcpy(st, ctime(&now)); st[strlen(st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - ((int) strlen(st))*8, 0, w); strncpy(st, cls.servername, sizeof(st)); st[sizeof(st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - ((int) strlen(st))*8, 10, w); strncpy(st, name.string, sizeof(st)); st[sizeof(st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - ((int) strlen(st))*8, 20, w); WritePCXfile (pcxname, newbuf, w, h, w, host_basepal, true); free(newbuf); D_DisableBackBufferAccess (); // for adapters that can't stay mapped in // for linear writes all the time // Con_Printf ("Wrote %s\n", pcxname); Con_Printf ("Sending shot to server...\n"); }
/* SCR_RSShot_f */ void SCR_RSShot_f (void) { int x, y; unsigned char *src, *dest; char pcxname[80]; unsigned char *newbuf; int w, h; int dx, dy, dex, dey, nx; int r, b, g; int count; float fracw, frach; char st[80]; time_t now; if (CL_IsUploading ()) return; // already one pending if (cls.state < ca_onserver) return; // gotta be connected Con_Printf ("Remote screen shot requested.\n"); snprintf (pcxname, sizeof (pcxname), "rss.pcx"); // // save the pcx file // newbuf = malloc (glheight * glwidth * 3); glReadPixels (glx, gly, glwidth, glheight, GL_RGB, GL_UNSIGNED_BYTE, newbuf); w = (vid.width < RSSHOT_WIDTH) ? glwidth : RSSHOT_WIDTH; h = (vid.height < RSSHOT_HEIGHT) ? glheight : RSSHOT_HEIGHT; fracw = (float) glwidth / (float) w; frach = (float) glheight / (float) h; for (y = 0; y < h; y++) { dest = newbuf + (w * 3 * y); for (x = 0; x < w; x++) { r = g = b = 0; dx = x * fracw; dex = (x + 1) * fracw; if (dex == dx) dex++; // at least one dy = y * frach; dey = (y + 1) * frach; if (dey == dy) dey++; // at least one count = 0; for ( /* */ ; dy < dey; dy++) { src = newbuf + (glwidth * 3 * dy) + dx * 3; for (nx = dx; nx < dex; nx++) { r += *src++; g += *src++; b += *src++; count++; } } r /= count; g /= count; b /= count; *dest++ = r; *dest++ = b; *dest++ = g; } } // convert to eight bit for (y = 0; y < h; y++) { src = newbuf + (w * 3 * y); dest = newbuf + (w * y); for (x = 0; x < w; x++) { *dest++ = MipColor (src[0], src[1], src[2]); src += 3; } } time (&now); strcpy (st, ctime (&now)); st[strlen (st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - strlen (st) * 8, h - 1, w); strncpy (st, cls.servername, sizeof (st)); st[sizeof (st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - strlen (st) * 8, h - 11, w); strncpy (st, name->string, sizeof (st)); st[sizeof (st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - strlen (st) * 8, h - 21, w); WritePCXfile (pcxname, newbuf, w, h, w, host_basepal, true, true); free (newbuf); Con_Printf ("Wrote %s\n", pcxname); Con_Printf ("Sending shot to server...\n"); }