X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=image.c;h=3ecbea398671fe3ecb5310f5cae3f1183e5fdf1b;hb=67a5b8dba9431970132086fe1d77e5526d71b23e;hp=ec9d68590dd93dd55662bd08288592f00df71851;hpb=d86fcb15e2ac521be6248e3655023363f7241ddb;p=xonotic%2Fdarkplaces.git diff --git a/image.c b/image.c index ec9d6859..3ecbea39 100644 --- a/image.c +++ b/image.c @@ -32,7 +32,7 @@ void Image_CopyMux(qbyte *outpixels, const qbyte *inpixels, int inputwidth, int else { for (y = 0, line = inpixels + row_ofs; y < inputheight; y++, line += row_inc) - for (x = 0, in = line + col_ofs; x < inputwidth; x++, in += col_inc, outpixels += 3) + for (x = 0, in = line + col_ofs; x < inputwidth; x++, in += col_inc, outpixels += numinputcomponents) for (c = 0; c < numoutputcomponents; c++) outpixels[c] = ((index = outputinputcomponentindices[c]) & 0x80000000) ? index : in[index]; } @@ -50,7 +50,7 @@ void Image_CopyMux(qbyte *outpixels, const qbyte *inpixels, int inputwidth, int else { for (y = 0, line = inpixels + row_ofs; y < inputheight; y++, line += row_inc) - for (x = 0, in = line + col_ofs; x < inputwidth; x++, in += col_inc, outpixels += 3) + for (x = 0, in = line + col_ofs; x < inputwidth; x++, in += col_inc, outpixels += numinputcomponents) for (c = 0; c < numoutputcomponents; c++) outpixels[c] = in[outputinputcomponentindices[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; } @@ -1310,7 +1307,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 +1502,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); /*