diff --git a/src/driver/pictureviewer/crw.cpp b/src/driver/pictureviewer/crw.cpp index e081aba57..1de75cdc7 100644 --- a/src/driver/pictureviewer/crw.cpp +++ b/src/driver/pictureviewer/crw.cpp @@ -173,7 +173,7 @@ int fh_crw_load(const char *filename,unsigned char **buffer,int* xp,int* /*yp*/) struct jpeg_decompress_struct *ciptr; struct r_crw_jpeg_error_mgr emgr; unsigned char *bp; - int px/*,py*/,c,x=*xp; + int px/*,py*/,c,x=*xp, ix; FILE *fh; JSAMPLE *lb; @@ -195,21 +195,22 @@ int fh_crw_load(const char *filename,unsigned char **buffer,int* xp,int* /*yp*/) jpeg_stdio_src(ciptr,fh); jpeg_read_header(ciptr,TRUE); ciptr->out_color_space=JCS_RGB; - if(x==(int)ciptr->image_width) + ix = (int)ciptr->image_width; + if (x == ix) ciptr->scale_denom=1; #if __cplusplus < 201103 - else if(abs(x*2 - ciptr->image_width) < 2) + else if (abs(x*2 - ix) < 2) ciptr->scale_denom=2; - else if(abs(x*4 - ciptr->image_width) < 4) + else if (abs(x*4 - ix) < 4) ciptr->scale_denom=4; - else if(abs(x*8 - ciptr->image_width) < 8) + else if (abs(x*8 - ix) < 8) ciptr->scale_denom=8; #else - else if(std::abs(x*2 - ciptr->image_width) < 2) + else if (std::abs(x*2 - ix) < 2) ciptr->scale_denom=2; - else if(std::abs(x*4 - ciptr->image_width) < 4) + else if (std::abs(x*4 - ix) < 4) ciptr->scale_denom=4; - else if(std::abs(x*8 - ciptr->image_width) < 8) + else if (std::abs(x*8 - ix) < 8) ciptr->scale_denom=8; #endif else diff --git a/src/driver/pictureviewer/jpeg.cpp b/src/driver/pictureviewer/jpeg.cpp index accb8a512..a61c91229 100644 --- a/src/driver/pictureviewer/jpeg.cpp +++ b/src/driver/pictureviewer/jpeg.cpp @@ -72,7 +72,7 @@ int fh_jpeg_load(const char *filename,unsigned char **buffer,int* x,int* y) struct jpeg_decompress_struct *ciptr; struct r_jpeg_error_mgr emgr; unsigned char *bp; - int px,py,c; + int px,py,c, ix; FILE *fh; JSAMPLE *lb; @@ -94,21 +94,22 @@ int fh_jpeg_load(const char *filename,unsigned char **buffer,int* x,int* y) jpeg_read_header(ciptr,TRUE); ciptr->out_color_space=JCS_RGB; ciptr->dct_method=JDCT_FASTEST; - if(*x==(int)ciptr->image_width) + ix = (int)ciptr->image_width; + if(*x == ix) ciptr->scale_denom=1; #if __cplusplus < 201103 - else if(abs(*x*2 - ciptr->image_width) < 2) + else if (abs(*x*2 - ix) < 2) ciptr->scale_denom=2; - else if(abs(*x*4 - ciptr->image_width) < 4) + else if (abs(*x*4 - ix) < 4) ciptr->scale_denom=4; - else if(abs(*x*8 - ciptr->image_width) < 8) + else if (abs(*x*8 - ix) < 8) ciptr->scale_denom=8; #else - else if(std::abs(*x*2 - ciptr->image_width) < 2) + else if (std::abs(*x*2 - ix) < 2) ciptr->scale_denom=2; - else if(std::abs(*x*4 - ciptr->image_width) < 4) + else if (std::abs(*x*4 - ix) < 4) ciptr->scale_denom=4; - else if(std::abs(*x*8 - ciptr->image_width) < 8) + else if (std::abs(*x*8 - ix) < 8) ciptr->scale_denom=8; #endif else