diff --git a/code/renderergl1/tr_init.c b/code/renderergl1/tr_init.c index e3f91d43f..07c2e2f17 100644 --- a/code/renderergl1/tr_init.c +++ b/code/renderergl1/tr_init.c @@ -484,11 +484,10 @@ sampled down from full screen distorted images static void R_LevelShot(screenshotType_e type, const char *ext) { char fileName[MAX_OSPATH]; byte *source, *allsource; - byte *resample, *resamplestart; + byte *resample; size_t offset = 0, memcount; - int spadlen, rpadlen; - int padwidth, linelen; - GLint packAlign = 1; + int spadlen; + int linelen; byte *src, *dst; int x, y; int r, g, b; @@ -515,15 +514,9 @@ static void R_LevelShot(screenshotType_e type, const char *ext) { source = allsource + offset; linelen = width * 3; - padwidth = spadlen + linelen; - - // Allocate a few more bytes so that we can choose an alignment we like - resample = ri.Hunk_AllocateTempMemory(padwidth * height + offset + packAlign - 1); + memcount = linelen * height; - resamplestart = PADP((intptr_t) resample + offset, packAlign); - - offset = resamplestart - resample; - rpadlen = padwidth - linelen; + resample = ri.Hunk_AllocateTempMemory(memcount); // resample from source xScale = glConfig.vidWidth / (float)(width * 4.0f); @@ -547,18 +540,16 @@ static void R_LevelShot(screenshotType_e type, const char *ext) { } } - memcount = (width * 3 + rpadlen) * height; - // gamma correct if (glConfig.deviceSupportsGamma) - R_GammaCorrect(resample + offset, memcount); + R_GammaCorrect(resample, memcount); if (type == ST_TGA) - RE_SaveTGA(fileName, width, height, resample + offset, rpadlen); + RE_SaveTGA(fileName, width, height, resample, 0); else if (type == ST_JPEG) - RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, resample + offset, rpadlen); + RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, resample, 0); else if (type == ST_PNG) - RE_SavePNG(fileName, width, height, resample + offset, rpadlen); + RE_SavePNG(fileName, width, height, resample, 0); ri.Hunk_FreeTempMemory(resample); ri.Hunk_FreeTempMemory(allsource); diff --git a/code/renderergl2/tr_init.c b/code/renderergl2/tr_init.c index 0414d2320..90c608838 100644 --- a/code/renderergl2/tr_init.c +++ b/code/renderergl2/tr_init.c @@ -573,11 +573,10 @@ the menu system, sampled down from full screen distorted images static void R_LevelShot(screenshotType_e type, const char *ext) { char fileName[MAX_OSPATH]; byte *source, *allsource; - byte *resample, *resamplestart; + byte *resample; size_t offset = 0, memcount; - int spadlen, rpadlen; - int padwidth, linelen; - GLint packAlign = 1; + int spadlen; + int linelen; byte *src, *dst; int x, y; int r, g, b; @@ -604,15 +603,9 @@ static void R_LevelShot(screenshotType_e type, const char *ext) { source = allsource + offset; linelen = width * 3; - padwidth = spadlen + linelen; - - // Allocate a few more bytes so that we can choose an alignment we like - resample = ri.Hunk_AllocateTempMemory(padwidth * height + offset + packAlign - 1); + memcount = linelen * height; - resamplestart = PADP((intptr_t) resample + offset, packAlign); - - offset = resamplestart - resample; - rpadlen = padwidth - linelen; + resample = ri.Hunk_AllocateTempMemory(memcount); // resample from source xScale = glConfig.vidWidth / (float)(width * 4.0f); @@ -636,19 +629,17 @@ static void R_LevelShot(screenshotType_e type, const char *ext) { } } - memcount = (width * 3 + rpadlen) * height; - // gamma correction if (glConfig.deviceSupportsGamma) { - R_GammaCorrect(resample + offset, memcount); + R_GammaCorrect(resample, memcount); } if (type == ST_TGA) - RE_SaveTGA(fileName, width, height, resample + offset, rpadlen); + RE_SaveTGA(fileName, width, height, resample, 0); else if (type == ST_JPEG) - RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, resample + offset, rpadlen); + RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, resample, 0); else if (type == ST_PNG) - RE_SavePNG(fileName, width, height, resample + offset, rpadlen); + RE_SavePNG(fileName, width, height, resample, 0); ri.Hunk_FreeTempMemory(resample); ri.Hunk_FreeTempMemory(allsource);