diff --git a/neo/renderer/Image.h b/neo/renderer/Image.h index 34515a37..5eac4531 100644 --- a/neo/renderer/Image.h +++ b/neo/renderer/Image.h @@ -468,7 +468,7 @@ FIXME: make an "imageBlock" type to hold byte*,width,height? byte *R_Dropsample( const byte *in, int inwidth, int inheight, int outwidth, int outheight ); byte *R_ResampleTexture( const byte *in, int inwidth, int inheight, - int outwidth, int outheight ); + int& outwidth, int& outheight ); byte *R_MipMapWithAlphaSpecularity( const byte *in, int width, int height ); byte *R_MipMap( const byte *in, int width, int height, bool preserveBorder ); byte *R_MipMap3D( const byte *in, int width, int height, int depth, bool preserveBorder ); diff --git a/neo/renderer/Image_files.cpp b/neo/renderer/Image_files.cpp index 174d544d..7871bc58 100644 --- a/neo/renderer/Image_files.cpp +++ b/neo/renderer/Image_files.cpp @@ -902,12 +902,18 @@ void R_LoadImage( const char *cname, byte **pic, int *width, int *height, ID_TIM if ( globalImages->image_roundDown.GetBool() && scaled_height > h ) { scaled_height >>= 1; } + int outWidth = scaled_width; + int outHeight = scaled_height; + resampledBuffer = R_ResampleTexture( *pic, w, h, outWidth, outHeight ); + if ( outWidth != scaled_width || outHeight != scaled_height ) { + common->Warning( "Texture '%s' didn't have power-of-two size *and* was too big, scaled from %dx%d to %dx%d", + name.c_str(), w, h, outWidth, outHeight ); + } - resampledBuffer = R_ResampleTexture( *pic, w, h, scaled_width, scaled_height ); R_StaticFree( *pic ); *pic = resampledBuffer; - *width = scaled_width; - *height = scaled_height; + *width = outWidth; + *height = outHeight; } } } diff --git a/neo/renderer/Image_process.cpp b/neo/renderer/Image_process.cpp index 920aad18..6027d930 100644 --- a/neo/renderer/Image_process.cpp +++ b/neo/renderer/Image_process.cpp @@ -46,7 +46,7 @@ after resampling to the next lower power of two. */ #define MAX_DIMENSION 4096 byte *R_ResampleTexture( const byte *in, int inwidth, int inheight, - int outwidth, int outheight ) { + int& _outwidth, int& _outheight ) { int i, j; const byte *inrow, *inrow2; unsigned int frac, fracstep; @@ -54,12 +54,14 @@ byte *R_ResampleTexture( const byte *in, int inwidth, int inheight, const byte *pix1, *pix2, *pix3, *pix4; byte *out, *out_p; - if ( outwidth > MAX_DIMENSION ) { - outwidth = MAX_DIMENSION; + if ( _outwidth > MAX_DIMENSION ) { + _outwidth = MAX_DIMENSION; } - if ( outheight > MAX_DIMENSION ) { - outheight = MAX_DIMENSION; + if ( _outheight > MAX_DIMENSION ) { + _outheight = MAX_DIMENSION; } + int outwidth = _outwidth; + int outheight = _outheight; out = (byte *)R_StaticAlloc( outwidth * outheight * 4 ); out_p = out;