From 3671d7a4fcfe8c9c7bff0f96c2edbc2041647053 Mon Sep 17 00:00:00 2001 From: Michael Haubenwallner Date: Fri, 7 Oct 2016 15:48:05 +0200 Subject: [PATCH] silence cl.exe /RTCc alerts in unfilterScanline() The /RTCc flag to cl.exe does (short description): Enable checking for conversion to smaller types (incompatible with any optimization type other than debug). --- lodepng.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lodepng.cpp b/lodepng.cpp index bf237df8..6ca3ee28 100644 --- a/lodepng.cpp +++ b/lodepng.cpp @@ -3986,12 +3986,12 @@ static unsigned unfilterScanline(unsigned char* recon, const unsigned char* scan break; case 1: for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i]; - for(i = bytewidth; i < length; ++i) recon[i] = scanline[i] + recon[i - bytewidth]; + for(i = bytewidth; i < length; ++i) recon[i] = 0xFF & (scanline[i] + recon[i - bytewidth]); break; case 2: if(precon) { - for(i = 0; i != length; ++i) recon[i] = scanline[i] + precon[i]; + for(i = 0; i != length; ++i) recon[i] = 0xFF & (scanline[i] + precon[i]); } else { @@ -4001,13 +4001,13 @@ static unsigned unfilterScanline(unsigned char* recon, const unsigned char* scan case 3: if(precon) { - for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i] + (precon[i] >> 1); - for(i = bytewidth; i < length; ++i) recon[i] = scanline[i] + ((recon[i - bytewidth] + precon[i]) >> 1); + for(i = 0; i != bytewidth; ++i) recon[i] = 0xFF & (scanline[i] + (precon[i] >> 1)); + for(i = bytewidth; i < length; ++i) recon[i] = 0xFF & (scanline[i] + ((recon[i - bytewidth] + precon[i]) >> 1)); } else { for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i]; - for(i = bytewidth; i < length; ++i) recon[i] = scanline[i] + (recon[i - bytewidth] >> 1); + for(i = bytewidth; i < length; ++i) recon[i] = 0xFF & (scanline[i] + (recon[i - bytewidth] >> 1)); } break; case 4: @@ -4015,11 +4015,11 @@ static unsigned unfilterScanline(unsigned char* recon, const unsigned char* scan { for(i = 0; i != bytewidth; ++i) { - recon[i] = (scanline[i] + precon[i]); /*paethPredictor(0, precon[i], 0) is always precon[i]*/ + recon[i] = 0xFF & (scanline[i] + precon[i]); /*paethPredictor(0, precon[i], 0) is always precon[i]*/ } for(i = bytewidth; i < length; ++i) { - recon[i] = (scanline[i] + paethPredictor(recon[i - bytewidth], precon[i], precon[i - bytewidth])); + recon[i] = 0xFF & (scanline[i] + paethPredictor(recon[i - bytewidth], precon[i], precon[i - bytewidth])); } } else @@ -4031,7 +4031,7 @@ static unsigned unfilterScanline(unsigned char* recon, const unsigned char* scan for(i = bytewidth; i < length; ++i) { /*paethPredictor(recon[i - bytewidth], 0, 0) is always recon[i - bytewidth]*/ - recon[i] = (scanline[i] + recon[i - bytewidth]); + recon[i] = 0xFF & (scanline[i] + recon[i - bytewidth]); } } break;