]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - image.c
308
[xonotic/darkplaces.git] / image.c
diff --git a/image.c b/image.c
index f7cf892d4a2dcb453bd7fdaa6d8a1531222faadf..7ef2326b0c5af4ea41f57a7cba31f5588920da49 100644 (file)
--- a/image.c
+++ b/image.c
@@ -853,14 +853,12 @@ rtexture_t *loadtextureimagebumpasnmap (rtexturepool_t *pool, const char *filena
        return rt;
 }
 
-qboolean Image_WriteTGARGB_preflipped (const char *filename, int width, int height, const qbyte *data)
+qboolean Image_WriteTGARGB_preflipped (const char *filename, int width, int height, const qbyte *data, qbyte *buffer)
 {
        qboolean ret;
-       qbyte *buffer, *out;
+       qbyte *out;
        const qbyte *in, *end;
 
-       buffer = Mem_Alloc(tempmempool, width*height*3 + 18);
-
        memset (buffer, 0, 18);
        buffer[2] = 2;          // uncompressed type
        buffer[12] = (width >> 0) & 0xFF;
@@ -881,7 +879,6 @@ qboolean Image_WriteTGARGB_preflipped (const char *filename, int width, int heig
        }
        ret = FS_WriteFile (filename, buffer, width*height*3 + 18 );
 
-       Mem_Free(buffer);
        return ret;
 }
 
@@ -934,6 +931,7 @@ void Image_WriteTGARGBA (const char *filename, int width, int height, const qbyt
        buffer[14] = (height >> 0) & 0xFF;
        buffer[15] = (height >> 8) & 0xFF;
        buffer[16] = 32;        // pixel size
+       buffer[17] = 8; // transparent flag? (seems to be needed by gimp)
 
        // swap rgba to bgra and flip upside down
        out = buffer + 18;
@@ -1310,7 +1308,7 @@ void Image_Resample (const void *indata, int inwidth, int inheight, int indepth,
                        Mem_Free(resamplerow1);
                resamplerowsize = outwidth*4;
                if (!resamplemempool)
-                       resamplemempool = Mem_AllocPool("Image Scaling Buffer");
+                       resamplemempool = Mem_AllocPool("Image Scaling Buffer", 0, NULL);
                resamplerow1 = Mem_Alloc(resamplemempool, resamplerowsize*2);
                resamplerow2 = resamplerow1 + resamplerowsize;
        }
@@ -1505,8 +1503,8 @@ void Image_HeightmapToNormalmap(const unsigned char *inpixels, unsigned char *ou
                        n[1] = dv[0][2]*dv[1][0]-dv[0][0]*dv[1][2];
                        n[2] = dv[0][0]*dv[1][1]-dv[0][1]*dv[1][0];
                        */
-                       n[0] = ((p1[0] + p1[1] + p1[2]) - (p0[0] + p0[1] + p0[2]));
-                       n[1] = ((p0[0] + p0[1] + p0[2]) - (p2[0] + p2[1] + p2[2]));
+                       n[0] = ((p0[0] + p0[1] + p0[2]) - (p1[0] + p1[1] + p1[2]));
+                       n[1] = ((p2[0] + p2[1] + p2[2]) - (p0[0] + p0[1] + p0[2]));
                        n[2] = ibumpscale;
                        VectorNormalize(n);
                        /*