diff --git a/code/renderer/tr_image.c b/code/renderer/tr_image.c index e8f116d..2df0703 100644 --- a/code/renderer/tr_image.c +++ b/code/renderer/tr_image.c @@ -1133,13 +1133,15 @@ void kuwahara(int columns, int rows, byte *targa_rgba) byte getImageR(byte *targa_rgba, int x, int y, int columns, int rows) { byte *pixbuf; - + + if((x<0)||(x>=columns)||(y<0)||(y>rows)) + return 0; + x*=((x<0)?-1:1); y*=((y<0)?-1:1); pixbuf = targa_rgba + y*columns*4; - - + if(columns=columns)||(y<0)||(y>rows)) + return; pixbuf = targa_rgba + y*columns*4; @@ -1168,7 +1172,10 @@ void setImageR(byte *targa_rgba, int x, int y, int columns, int rows, byte value //GREEN byte getImageG(byte *targa_rgba, int x, int y, int columns, int rows) { - byte *pixbuf; + byte *pixbuf; + + if((x<0)||(x>=columns)||(y<0)||(y>rows)) + return 0; x*=((x<0)?-1:1); y*=((y<0)?-1:1); @@ -1191,8 +1198,10 @@ void setImageG(byte *targa_rgba, int x, int y, int columns, int rows, byte value { byte *pixbuf; - x*=((x<0)?-1:1); - y*=((y<0)?-1:1); + /*x*=((x<0)?-1:1); + y*=((y<0)?-1:1);*/ + if((x<0)||(x>=columns)||(y<0)||(y>rows)) + return; pixbuf = targa_rgba + y*columns*4; @@ -1204,7 +1213,10 @@ void setImageG(byte *targa_rgba, int x, int y, int columns, int rows, byte value byte getImageB(byte *targa_rgba, int x, int y, int columns, int rows) { byte *pixbuf; - + + if((x<0)||(x>=columns)||(y<0)||(y>rows)) + return 0; + x*=((x<0)?-1:1); y*=((y<0)?-1:1); @@ -1225,8 +1237,10 @@ void setImageB(byte *targa_rgba, int x, int y, int columns, int rows, byte value { byte *pixbuf; - x*=((x<0)?-1:1); - y*=((y<0)?-1:1); + /*x*=((x<0)?-1:1); + y*=((y<0)?-1:1);*/ + if((x<0)||(x>=columns)||(y<0)||(y>rows)) + return; pixbuf = targa_rgba + y*columns*4; @@ -1239,8 +1253,10 @@ byte getImageA(byte *targa_rgba, int x, int y, int columns, int rows) { byte *pixbuf; - x*=((x<0)?-1:1); - y*=((y<0)?-1:1); + /*x*=((x<0)?-1:1); + y*=((y<0)?-1:1);*/ + if((x<0)||(x>=columns)||(y<0)||(y>rows)) + return 0; pixbuf = targa_rgba + y*columns*4; @@ -1253,8 +1269,10 @@ void setImageA(byte *targa_rgba, int x, int y, int columns, int rows, byte value { byte *pixbuf; - x*=((x<0)?-1:1); - y*=((y<0)?-1:1); + /*x*=((x<0)?-1:1); + y*=((y<0)?-1:1);*/ + if((x<0)||(x>=columns)||(y<0)||(y>rows)) + return; pixbuf = targa_rgba + y*columns*4; @@ -1436,12 +1454,7 @@ static void LoadBMP( const char *name, byte **pic, int *width, int *height ) } } } - - if(r_celshadalgo->integer==1) - kuwahara(columns,rows ,bmpRGBA); - else if(r_celshadalgo->integer==2) - whiteTexture(columns,rows,bmpRGBA); - + ri.FS_FreeFile( buffer ); } @@ -1547,12 +1560,6 @@ static void LoadPCX ( const char *filename, byte **pic, byte **palette, int *wid *pic = NULL; } - if(r_celshadalgo->integer==1) - kuwahara(xmax,ymax ,pic); - else if(r_celshadalgo->integer==2) - whiteTexture(xmax,ymax ,pic); - - ri.FS_FreeFile (pcx); } @@ -1585,13 +1592,6 @@ static void LoadPCX32 ( const char *filename, byte **pic, int *width, int *heigh pic32 += 4; } - - if(r_celshadalgo->integer==1) - kuwahara(*width,*height ,pic32); - else if(r_celshadalgo->integer==2) - whiteTexture(*width,*height ,pic32); - - ri.Free (pic8); ri.Free (palette); } @@ -1846,13 +1846,6 @@ static void LoadTGA ( const char *name, byte **pic, int *width, int *height) } } -/*jpc algorismes*/ - - if(r_celshadalgo->integer==1) - kuwahara(columns,rows ,targa_rgba); - else if(r_celshadalgo->integer==2) - whiteTexture(columns,rows ,targa_rgba); - #if 0 // TTimo: this is the chunk of code to ensure a behavior that meets TGA specs @@ -1999,12 +1992,6 @@ static void LoadJPG( const char *filename, unsigned char **pic, int *width, int } } - - if(r_celshadalgo->integer==1) - kuwahara(*width,*height ,*pic); - else if(r_celshadalgo->integer==2) - whiteTexture(*width,*height ,*pic); - /* Step 7: Finish decompression */ (void) jpeg_finish_decompress(&cinfo); @@ -2371,7 +2358,11 @@ void R_LoadImage( const char *name, byte **pic, int *width, int *height ) { LoadBMP( name, pic, width, height ); } else if ( !Q_stricmp( name+len-4, ".jpg" ) ) { LoadJPG( name, pic, width, height ); - } + } + if(r_celshadalgo->integer==1) + kuwahara(*width,*height,pic); + else if(r_celshadalgo->integer==2) + whiteTexture(*width,*height,pic); }