]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
make screenshots rightside up again (or rather, upside down like TGA wants, which...
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 29 Jan 2001 06:10:57 +0000 (06:10 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 29 Jan 2001 06:10:57 +0000 (06:10 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@137 d7cf8633-e32d-0410-b094-e92efae38249

gl_screen.c
image.c
image.h

index 722dfa60b403d09ed3e941db95be22d0478380c5..045afa6e910341a1ab8ab0d04026b811473dd2e6 100644 (file)
@@ -617,7 +617,7 @@ void SCR_ScreenShot_f (void)
 
        buffer = malloc(glwidth*glheight*3);
        glReadPixels (glx, gly, glwidth, glheight, GL_RGB, GL_UNSIGNED_BYTE, buffer); 
 
        buffer = malloc(glwidth*glheight*3);
        glReadPixels (glx, gly, glwidth, glheight, GL_RGB, GL_UNSIGNED_BYTE, buffer); 
-       Image_WriteTGARGB(filename, glwidth, glheight, buffer);
+       Image_WriteTGARGB_preflipped(filename, glwidth, glheight, buffer);
 
        free (buffer);
        Con_Printf ("Wrote %s\n", filename);
 
        free (buffer);
        Con_Printf ("Wrote %s\n", filename);
diff --git a/image.c b/image.c
index f4520e98da81c62aa1633217a2991d2fb8e2fdaa..4ba317076f64451a9327387cdcd16bf4dccb9a26 100644 (file)
--- a/image.c
+++ b/image.c
@@ -539,6 +539,35 @@ int loadtextureimagewithmask (char* filename, int matchwidth, int matchheight, q
        return texnum;
 }
 
        return texnum;
 }
 
+void Image_WriteTGARGB_preflipped (char *filename, int width, int height, byte *data)
+{
+       byte *buffer, *in, *out, *end;
+
+       buffer = malloc(width*height*3 + 18);
+
+       memset (buffer, 0, 18);
+       buffer[2] = 2;          // uncompressed type
+       buffer[12] = (width >> 0) & 0xFF;
+       buffer[13] = (width >> 8) & 0xFF;
+       buffer[14] = (height >> 0) & 0xFF;
+       buffer[15] = (height >> 8) & 0xFF;
+       buffer[16] = 24;        // pixel size
+
+       // swap rgb to bgr
+       in = data;
+       out = buffer + 18;
+       end = in + width*height*3;
+       for (;in < end;in += 3)
+       {
+               *out++ = in[2];
+               *out++ = in[1];
+               *out++ = in[0];
+       }
+       COM_WriteFile (filename, buffer, width*height*3 + 18 );
+
+       free(buffer);
+}
+
 void Image_WriteTGARGB (char *filename, int width, int height, byte *data)
 {
        int y;
 void Image_WriteTGARGB (char *filename, int width, int height, byte *data)
 {
        int y;
diff --git a/image.h b/image.h
index 20096ff84427661824a82e1d7b7ae9a7596ab3b7..ebaafd584bea79ff59c07daf06bceb4da81a9356 100644 (file)
--- a/image.h
+++ b/image.h
@@ -8,5 +8,6 @@ extern byte* loadimagepixelsmask (char* filename, qboolean complain, int matchwi
 extern int loadtextureimagemask (char* filename, int matchwidth, int matchheight, qboolean complain, qboolean mipmap);
 extern int image_masktexnum;
 extern int loadtextureimagewithmask (char* filename, int matchwidth, int matchheight, qboolean complain, qboolean mipmap);
 extern int loadtextureimagemask (char* filename, int matchwidth, int matchheight, qboolean complain, qboolean mipmap);
 extern int image_masktexnum;
 extern int loadtextureimagewithmask (char* filename, int matchwidth, int matchheight, qboolean complain, qboolean mipmap);
+extern void Image_WriteTGARGB_preflipped (char *filename, int width, int height, byte *data);
 extern void Image_WriteTGARGB (char *filename, int width, int height, byte *data);
 extern void Image_WriteTGARGBA (char *filename, int width, int height, byte *data);
 extern void Image_WriteTGARGB (char *filename, int width, int height, byte *data);
 extern void Image_WriteTGARGBA (char *filename, int width, int height, byte *data);