Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions lodepng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for
#if defined(_MSC_VER) && (_MSC_VER >= 1310) /*Visual Studio: A few warning types are not desired here.*/
#pragma warning( disable : 4244 ) /*implicit conversions: not warned by gcc -Wall -Wextra and requires too much casts*/
#pragma warning( disable : 4996 ) /*VS does not like fopen, but fopen_s is not standard C so unusable here*/
#pragma warning( disable : 4334 ) /*VS does not like fopen, but fopen_s is not standard C so unusable here*/
#endif /*_MSC_VER */

const char* LODEPNG_VERSION_STRING = "20161127";
Expand Down Expand Up @@ -1455,11 +1456,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] = (int)wpos;

hash->zeros[wpos] = numzeros;
if(hash->headz[numzeros] != -1) hash->chainz[wpos] = hash->headz[numzeros];
hash->headz[numzeros] = wpos;
hash->headz[numzeros] = (int)wpos;
}

/*
Expand Down Expand Up @@ -1531,7 +1532,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 <= wpos ? (unsigned int)wpos - hashpos : (unsigned int)wpos - hashpos + windowsize;

if(current_offset < prev_offset) break; /*stop when went completely around the circular buffer*/
prev_offset = current_offset;
Expand Down Expand Up @@ -3489,7 +3490,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 int)i);
}
}

Expand Down Expand Up @@ -4329,7 +4330,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 = chunkLength < string2_begin ? 0 : (unsigned int)chunkLength - string2_begin;
str = (char*)lodepng_malloc(length + 1);
if(!str) CERROR_BREAK(error, 83); /*alloc fail*/

Expand Down Expand Up @@ -4377,7 +4378,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 int)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]),
Expand Down Expand Up @@ -4457,7 +4458,7 @@ static unsigned readChunk_iTXt(LodePNGInfo* info, const LodePNGDecompressSetting
/*read the actual text*/
begin += length + 1;

length = chunkLength < begin ? 0 : chunkLength - begin;
length = chunkLength < begin ? 0 : (unsigned int)chunkLength - begin;

if(compressed)
{
Expand Down Expand Up @@ -5400,7 +5401,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);
Expand Down