From 682cffd4c854e09ea79c823223dbb589e3814d65 Mon Sep 17 00:00:00 2001 From: jobtalle Date: Sat, 18 Mar 2017 14:48:00 +0100 Subject: Fixed 64bit warnings produced by MSVC, issue #24 --- lodepng.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lodepng.cpp b/lodepng.cpp index bf237df..9f6093f 100644 --- a/lodepng.cpp +++ b/lodepng.cpp @@ -795,7 +795,7 @@ unsigned lodepng_huffman_code_lengths(unsigned* lengths, const unsigned* frequen BPMNode* leaves; /*the symbols, only those with > 0 frequency*/ if(numcodes == 0) return 80; /*error: a tree of 0 symbols is not supposed to be made*/ - if((1u << maxbitlen) < numcodes) return 80; /*error: represent all symbols*/ + if((1u << maxbitlen) < (unsigned)numcodes) return 80; /*error: represent all symbols*/ leaves = (BPMNode*)lodepng_malloc(numcodes * sizeof(*leaves)); if(!leaves) return 83; /*alloc fail*/ @@ -1455,11 +1455,11 @@ static void updateHashChain(Hash* hash, size_t wpos, unsigned hashval, unsigned { hash->val[wpos] = (int)hashval; if(hash->head[hashval] != -1) hash->chain[wpos] = hash->head[hashval]; - hash->head[hashval] = wpos; + hash->head[hashval] = (unsigned)wpos; hash->zeros[wpos] = numzeros; if(hash->headz[numzeros] != -1) hash->chainz[wpos] = hash->headz[numzeros]; - hash->headz[numzeros] = wpos; + hash->headz[numzeros] = (unsigned)wpos; } /* @@ -1531,7 +1531,7 @@ static unsigned encodeLZ77(uivector* out, Hash* hash, for(;;) { if(chainlength++ >= maxchainlength) break; - current_offset = hashpos <= wpos ? wpos - hashpos : wpos - hashpos + windowsize; + current_offset = hashpos <= (unsigned)(wpos?wpos - hashpos:wpos - hashpos + windowsize); if(current_offset < prev_offset) break; /*stop when went completely around the circular buffer*/ prev_offset = current_offset; @@ -3489,7 +3489,7 @@ unsigned lodepng_convert(unsigned char* out, const unsigned char* in, for(i = 0; i != palsize; ++i) { const unsigned char* p = &palette[i * 4]; - color_tree_add(&tree, p[0], p[1], p[2], p[3], i); + color_tree_add(&tree, p[0], p[1], p[2], p[3], (unsigned)i); } } @@ -4329,7 +4329,7 @@ static unsigned readChunk_tEXt(LodePNGInfo* info, const unsigned char* data, siz string2_begin = length + 1; /*skip keyword null terminator*/ - length = chunkLength < string2_begin ? 0 : chunkLength - string2_begin; + length = (unsigned)(chunkLength < string2_begin?0:chunkLength - string2_begin); str = (char*)lodepng_malloc(length + 1); if(!str) CERROR_BREAK(error, 83); /*alloc fail*/ @@ -4377,7 +4377,7 @@ static unsigned readChunk_zTXt(LodePNGInfo* info, const LodePNGDecompressSetting string2_begin = length + 2; if(string2_begin > chunkLength) CERROR_BREAK(error, 75); /*no null termination, corrupt?*/ - length = chunkLength - string2_begin; + length = (unsigned)chunkLength - string2_begin; /*will fail if zlib error, e.g. if length is too small*/ error = zlib_decompress(&decoded.data, &decoded.size, (unsigned char*)(&data[string2_begin]), @@ -4457,7 +4457,7 @@ static unsigned readChunk_iTXt(LodePNGInfo* info, const LodePNGDecompressSetting /*read the actual text*/ begin += length + 1; - length = chunkLength < begin ? 0 : chunkLength - begin; + length = (unsigned)chunkLength < begin?0:(unsigned)chunkLength - begin; if(compressed) { @@ -5400,7 +5400,7 @@ static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w, { for(type = 0; type != 5; ++type) { - unsigned testsize = linebytes; + unsigned testsize = (unsigned)linebytes; /*if(testsize > 8) testsize /= 8;*/ /*it already works good enough by testing a part of the row*/ filterScanline(attempt[type], &in[y * linebytes], prevline, linebytes, bytewidth, type); -- cgit v1.2.3 From 15a974356701c0243f452e6c28edfa7aa8c3a532 Mon Sep 17 00:00:00 2001 From: jobtalle Date: Sat, 18 Mar 2017 14:50:12 +0100 Subject: Fixed formatting --- lodepng.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lodepng.cpp b/lodepng.cpp index 9f6093f..70381fb 100644 --- a/lodepng.cpp +++ b/lodepng.cpp @@ -1531,7 +1531,7 @@ static unsigned encodeLZ77(uivector* out, Hash* hash, for(;;) { if(chainlength++ >= maxchainlength) break; - current_offset = hashpos <= (unsigned)(wpos?wpos - hashpos:wpos - hashpos + windowsize); + current_offset = hashpos <= (unsigned)(wpos?wpos - hashpos:wpos - hashpos + windowsize); if(current_offset < prev_offset) break; /*stop when went completely around the circular buffer*/ prev_offset = current_offset; @@ -3489,7 +3489,7 @@ unsigned lodepng_convert(unsigned char* out, const unsigned char* in, for(i = 0; i != palsize; ++i) { const unsigned char* p = &palette[i * 4]; - color_tree_add(&tree, p[0], p[1], p[2], p[3], (unsigned)i); + color_tree_add(&tree, p[0], p[1], p[2], p[3], (unsigned)i); } } @@ -4329,7 +4329,7 @@ static unsigned readChunk_tEXt(LodePNGInfo* info, const unsigned char* data, siz string2_begin = length + 1; /*skip keyword null terminator*/ - length = (unsigned)(chunkLength < string2_begin?0:chunkLength - string2_begin); + length = (unsigned)(chunkLength < string2_begin?0:chunkLength - string2_begin); str = (char*)lodepng_malloc(length + 1); if(!str) CERROR_BREAK(error, 83); /*alloc fail*/ @@ -4377,7 +4377,7 @@ static unsigned readChunk_zTXt(LodePNGInfo* info, const LodePNGDecompressSetting string2_begin = length + 2; if(string2_begin > chunkLength) CERROR_BREAK(error, 75); /*no null termination, corrupt?*/ - length = (unsigned)chunkLength - string2_begin; + length = (unsigned)chunkLength - string2_begin; /*will fail if zlib error, e.g. if length is too small*/ error = zlib_decompress(&decoded.data, &decoded.size, (unsigned char*)(&data[string2_begin]), @@ -4457,7 +4457,7 @@ static unsigned readChunk_iTXt(LodePNGInfo* info, const LodePNGDecompressSetting /*read the actual text*/ begin += length + 1; - length = (unsigned)chunkLength < begin?0:(unsigned)chunkLength - begin; + length = (unsigned)chunkLength < begin?0:(unsigned)chunkLength - begin; if(compressed) { -- cgit v1.2.3