mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Fixed warnings in stb_image
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1543 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
ff367bdb57
commit
8bde578f90
@ -483,42 +483,6 @@
|
||||
<File
|
||||
RelativePath="..\..\src\SFML\Graphics\ImageLoader.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug DLL|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
WarningLevel="3"
|
||||
DisableSpecificWarnings="4611"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release DLL|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
WarningLevel="3"
|
||||
DisableSpecificWarnings="4611"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug static|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
WarningLevel="3"
|
||||
DisableSpecificWarnings="4611"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release static|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
WarningLevel="3"
|
||||
DisableSpecificWarnings="4611"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\SFML\Graphics\ImageLoader.hpp"
|
||||
|
@ -1015,13 +1015,13 @@ static stbi_uc *hdr_to_ldr(float *data, int x, int y, int comp)
|
||||
float z = (float) pow(data[i*comp+k]*h2l_scale_i, h2l_gamma_i) * 255 + 0.5f;
|
||||
if (z < 0) z = 0;
|
||||
if (z > 255) z = 255;
|
||||
output[i*comp + k] = float2int(z);
|
||||
output[i*comp + k] = (stbi_uc)float2int(z);
|
||||
}
|
||||
if (k < comp) {
|
||||
float z = data[i*comp+k] * 255 + 0.5f;
|
||||
if (z < 0) z = 0;
|
||||
if (z > 255) z = 255;
|
||||
output[i*comp + k] = float2int(z);
|
||||
output[i*comp + k] = (stbi_uc)float2int(z);
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
@ -1825,7 +1825,7 @@ static uint8 *resample_row_hv_2(uint8 *out, uint8 *in_near, uint8 *in_far, int w
|
||||
return out;
|
||||
}
|
||||
|
||||
static uint8 *resample_row_generic(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs)
|
||||
static uint8 *resample_row_generic(uint8 *out, uint8 *in_near, uint8 * /*in_far*/, int w, int hs)
|
||||
{
|
||||
// resample with nearest-neighbor
|
||||
int i,j;
|
||||
@ -3207,15 +3207,15 @@ static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp)
|
||||
mr = mg = mb = 0;
|
||||
if (compress == 0) {
|
||||
if (bpp == 32) {
|
||||
mr = 0xff << 16;
|
||||
mg = 0xff << 8;
|
||||
mb = 0xff << 0;
|
||||
ma = 0xff << 24;
|
||||
mr = (unsigned int)0xff << 16;
|
||||
mg = (unsigned int)0xff << 8;
|
||||
mb = (unsigned int)0xff << 0;
|
||||
ma = (unsigned int)0xff << 24;
|
||||
fake_a = 1; // @TODO: check for cases like alpha value is all 0 and switch it to 255
|
||||
} else {
|
||||
mr = 31 << 10;
|
||||
mg = 31 << 5;
|
||||
mb = 31 << 0;
|
||||
mr = (unsigned int)31 << 10;
|
||||
mg = (unsigned int)31 << 5;
|
||||
mb = (unsigned int)31 << 0;
|
||||
}
|
||||
} else if (compress == 3) {
|
||||
mr = get32le(s);
|
||||
@ -3253,9 +3253,9 @@ static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp)
|
||||
int z=0;
|
||||
if (psize == 0 || psize > 256) { free(out); return epuc("invalid", "Corrupt BMP"); }
|
||||
for (i=0; i < psize; ++i) {
|
||||
pal[i][2] = get8(s);
|
||||
pal[i][1] = get8(s);
|
||||
pal[i][0] = get8(s);
|
||||
pal[i][2] = (stbi_uc)get8(s);
|
||||
pal[i][1] = (stbi_uc)get8(s);
|
||||
pal[i][0] = (stbi_uc)get8(s);
|
||||
if (hsz != 12) get8(s);
|
||||
pal[i][3] = 255;
|
||||
}
|
||||
@ -3311,22 +3311,22 @@ static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp)
|
||||
if (easy) {
|
||||
for (i=0; i < (int) s->img_x; ++i) {
|
||||
int a;
|
||||
out[z+2] = get8(s);
|
||||
out[z+1] = get8(s);
|
||||
out[z+0] = get8(s);
|
||||
out[z+2] = (uint8)get8(s);
|
||||
out[z+1] = (uint8)get8(s);
|
||||
out[z+0] = (uint8)get8(s);
|
||||
z += 3;
|
||||
a = (easy == 2 ? get8(s) : 255);
|
||||
if (target == 4) out[z++] = a;
|
||||
if (target == 4) out[z++] = (uint8)a;
|
||||
}
|
||||
} else {
|
||||
for (i=0; i < (int) s->img_x; ++i) {
|
||||
uint32 v = (bpp == 16 ? get16le(s) : get32le(s));
|
||||
int a;
|
||||
out[z++] = shiftsigned(v & mr, rshift, rcount);
|
||||
out[z++] = shiftsigned(v & mg, gshift, gcount);
|
||||
out[z++] = shiftsigned(v & mb, bshift, bcount);
|
||||
out[z++] = (uint8)shiftsigned(v & mr, rshift, rcount);
|
||||
out[z++] = (uint8)shiftsigned(v & mg, gshift, gcount);
|
||||
out[z++] = (uint8)shiftsigned(v & mb, bshift, bcount);
|
||||
a = (ma ? shiftsigned(v & ma, ashift, acount) : 255);
|
||||
if (target == 4) out[z++] = a;
|
||||
if (target == 4) out[z++] = (uint8)a;
|
||||
}
|
||||
}
|
||||
skip(s, pad);
|
||||
@ -3849,7 +3849,7 @@ static stbi_uc *psd_load(stbi *s, int *x, int *y, int *comp, int req_comp)
|
||||
len++;
|
||||
count += len;
|
||||
while (len) {
|
||||
*p = get8(s);
|
||||
*p = (uint8)get8(s);
|
||||
p += 4;
|
||||
len--;
|
||||
}
|
||||
@ -3862,7 +3862,7 @@ static stbi_uc *psd_load(stbi *s, int *x, int *y, int *comp, int req_comp)
|
||||
val = get8(s);
|
||||
count += len;
|
||||
while (len) {
|
||||
*p = val;
|
||||
*p = (uint8)val;
|
||||
p += 4;
|
||||
len--;
|
||||
}
|
||||
@ -3886,7 +3886,7 @@ static stbi_uc *psd_load(stbi *s, int *x, int *y, int *comp, int req_comp)
|
||||
} else {
|
||||
// Read the data.
|
||||
for (i = 0; i < pixelCount; i++)
|
||||
*p = get8(s), p += 4;
|
||||
*p = (uint8)get8(s), p += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3974,7 +3974,7 @@ static stbi_uc *pic_readval(stbi *s, int channel, stbi_uc *dest)
|
||||
for (i=0; i<4; ++i, mask>>=1) {
|
||||
if (channel & mask) {
|
||||
if (at_eof(s)) return epuc("bad file","PIC file too short");
|
||||
dest[i]=get8(s);
|
||||
dest[i]=(stbi_uc)get8(s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4006,9 +4006,9 @@ static stbi_uc *pic_load2(stbi *s,int width,int height,int *comp, stbi_uc *resul
|
||||
packet = &packets[num_packets++];
|
||||
|
||||
chained = get8(s);
|
||||
packet->size = get8(s);
|
||||
packet->type = get8(s);
|
||||
packet->channel = get8(s);
|
||||
packet->size = (stbi_uc)get8(s);
|
||||
packet->type = (stbi_uc)get8(s);
|
||||
packet->channel = (stbi_uc)get8(s);
|
||||
|
||||
act_comp |= packet->channel;
|
||||
|
||||
@ -4045,11 +4045,11 @@ static stbi_uc *pic_load2(stbi *s,int width,int height,int *comp, stbi_uc *resul
|
||||
while (left>0) {
|
||||
stbi_uc count,value[4];
|
||||
|
||||
count=get8(s);
|
||||
count=(stbi_uc)get8(s);
|
||||
if (at_eof(s)) return epuc("bad file","file too short (pure read count)");
|
||||
|
||||
if (count > left)
|
||||
count = left;
|
||||
count = (stbi_uc)left;
|
||||
|
||||
if (!pic_readval(s,packet->channel,value)) return 0;
|
||||
|
||||
@ -4232,13 +4232,13 @@ int stbi_gif_test_memory (stbi_uc const *buffer, int len)
|
||||
return gif_test(&s);
|
||||
}
|
||||
|
||||
static void stbi_gif_parse_colortable(stbi *s, stbi_gif *g, uint8 pal[256][4], int num_entries, int transp)
|
||||
static void stbi_gif_parse_colortable(stbi *s, stbi_gif *g, uint8 /*pal*/[256][4], int num_entries, int transp)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < num_entries; ++i) {
|
||||
g->pal[i][2] = get8(s);
|
||||
g->pal[i][1] = get8(s);
|
||||
g->pal[i][0] = get8(s);
|
||||
g->pal[i][2] = (uint8)get8(s);
|
||||
g->pal[i][1] = (uint8)get8(s);
|
||||
g->pal[i][0] = (uint8)get8(s);
|
||||
g->pal[i][3] = transp ? 0 : 255;
|
||||
}
|
||||
}
|
||||
@ -4249,7 +4249,7 @@ static int stbi_gif_header(stbi *s, stbi_gif *g, int *comp, int is_info)
|
||||
if (get8(s) != 'G' || get8(s) != 'I' || get8(s) != 'F' || get8(s) != '8')
|
||||
return e("not GIF", "Corrupt GIF");
|
||||
|
||||
version = get8(s);
|
||||
version = (uint8)get8(s);
|
||||
if (version != '7' && version != '9') return e("not GIF", "Corrupt GIF");
|
||||
if (get8(s) != 'a') return e("not GIF", "Corrupt GIF");
|
||||
|
||||
@ -4322,7 +4322,7 @@ static uint8 *stbi_process_gif_raster(stbi *s, stbi_gif *g)
|
||||
int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear;
|
||||
stbi_gif_lzw *p;
|
||||
|
||||
lzw_cs = get8(s);
|
||||
lzw_cs = (uint8)get8(s);
|
||||
clear = 1 << lzw_cs;
|
||||
first = 1;
|
||||
codesize = lzw_cs + 1;
|
||||
@ -4331,8 +4331,8 @@ static uint8 *stbi_process_gif_raster(stbi *s, stbi_gif *g)
|
||||
valid_bits = 0;
|
||||
for (code = 0; code < clear; code++) {
|
||||
g->codes[code].prefix = -1;
|
||||
g->codes[code].first = code;
|
||||
g->codes[code].suffix = code;
|
||||
g->codes[code].first = (uint8)code;
|
||||
g->codes[code].suffix = (uint8)code;
|
||||
}
|
||||
|
||||
// support no starting clear code
|
||||
@ -4372,13 +4372,13 @@ static uint8 *stbi_process_gif_raster(stbi *s, stbi_gif *g)
|
||||
if (oldcode >= 0) {
|
||||
p = &g->codes[avail++];
|
||||
if (avail > 4096) return epuc("too many codes", "Corrupt GIF");
|
||||
p->prefix = oldcode;
|
||||
p->prefix = (int16)oldcode;
|
||||
p->first = g->codes[oldcode].first;
|
||||
p->suffix = (code == avail) ? p->first : g->codes[code].first;
|
||||
} else if (code == avail)
|
||||
return epuc("illegal code in raster", "Corrupt GIF");
|
||||
|
||||
stbi_out_gif_code(g, code);
|
||||
stbi_out_gif_code(g, (uint16)code);
|
||||
|
||||
if ((avail & codemask) == 0 && avail <= 0x0FFF) {
|
||||
codesize++;
|
||||
@ -4624,7 +4624,7 @@ static char *hdr_gettoken(stbi *z, char *buffer)
|
||||
int len=0;
|
||||
char c = '\0';
|
||||
|
||||
c = get8(z);
|
||||
c = (char)get8(z);
|
||||
|
||||
while (!at_eof(z) && c != '\n') {
|
||||
buffer[len++] = c;
|
||||
@ -4634,7 +4634,7 @@ static char *hdr_gettoken(stbi *z, char *buffer)
|
||||
;
|
||||
break;
|
||||
}
|
||||
c = get8(z);
|
||||
c = (char)get8(z);
|
||||
}
|
||||
|
||||
buffer[len] = 0;
|
||||
@ -4687,11 +4687,13 @@ static float *hdr_load(stbi *s, int *x, int *y, int *comp, int req_comp)
|
||||
return epf("not HDR", "Corrupt HDR image");
|
||||
|
||||
// Parse header
|
||||
while (1) {
|
||||
do {
|
||||
token = hdr_gettoken(s,buffer);
|
||||
if (token[0] == 0) break;
|
||||
if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1;
|
||||
}
|
||||
if (token[0] != 0) {
|
||||
if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0)
|
||||
valid = 1;
|
||||
}
|
||||
} while (token[0] != 0);
|
||||
|
||||
if (!valid) return epf("unsupported format", "Unsupported HDR format");
|
||||
|
||||
@ -4738,7 +4740,7 @@ static float *hdr_load(stbi *s, int *x, int *y, int *comp, int req_comp)
|
||||
if (c1 != 2 || c2 != 2 || (len & 0x80)) {
|
||||
// not run-length encoded, so we have to actually use THIS data as a decoded
|
||||
// pixel (note this can't be a valid pixel--one of RGB must be >= 128)
|
||||
stbi_uc rgbe[4] = { c1,c2,len, get8(s) };
|
||||
stbi_uc rgbe[4] = { (stbi_uc)c1,(stbi_uc)c2,(stbi_uc)len, (stbi_uc)get8(s) };
|
||||
hdr_convert(hdr_data, rgbe, req_comp);
|
||||
i = 1;
|
||||
j = 0;
|
||||
@ -4753,17 +4755,17 @@ static float *hdr_load(stbi *s, int *x, int *y, int *comp, int req_comp)
|
||||
for (k = 0; k < 4; ++k) {
|
||||
i = 0;
|
||||
while (i < width) {
|
||||
count = get8(s);
|
||||
count = (unsigned char)get8(s);
|
||||
if (count > 128) {
|
||||
// Run
|
||||
value = get8(s);
|
||||
value = (unsigned char)get8(s);
|
||||
count -= 128;
|
||||
for (z = 0; z < count; ++z)
|
||||
scanline[i++ * 4 + k] = value;
|
||||
} else {
|
||||
// Dump
|
||||
for (z = 0; z < count; ++z)
|
||||
scanline[i++ * 4 + k] = get8(s);
|
||||
scanline[i++ * 4 + k] = (stbi_uc)get8(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ static void writefv(FILE *f, const char *fmt, va_list v)
|
||||
while (*fmt) {
|
||||
switch (*fmt++) {
|
||||
case ' ': break;
|
||||
case '1': { unsigned char x = va_arg(v, int); fputc(x,f); break; }
|
||||
case '2': { int x = va_arg(v,int); unsigned char b[2]; b[0] = x; b[1] = x>>8; fwrite(b,2,1,f); break; }
|
||||
case '4': { stbiw_uint32 x = va_arg(v,int); unsigned char b[4]; b[0]=x; b[1]=x>>8; b[2]=x>>16; b[3]=x>>24; fwrite(b,4,1,f); break; }
|
||||
case '1': { unsigned char x = (unsigned char)va_arg(v, int); fputc(x,f); break; }
|
||||
case '2': { int x = va_arg(v,int); unsigned char b[2]; b[0] = (unsigned char)x; b[1] = (unsigned char)(x>>8); fwrite(b,2,1,f); break; }
|
||||
case '4': { stbiw_uint32 x = va_arg(v,int); unsigned char b[4]; b[0]=(unsigned char)x; b[1]=(unsigned char)(x>>8); b[2]=(unsigned char)(x>>16); b[3]=(unsigned char)(x>>24); fwrite(b,4,1,f); break; }
|
||||
default:
|
||||
assert(0);
|
||||
return;
|
||||
@ -205,7 +205,7 @@ static void *stbi__sbgrowf(void **arr, int increment, int itemsize)
|
||||
static unsigned char *stbi__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount)
|
||||
{
|
||||
while (*bitcount >= 8) {
|
||||
stbi__sbpush(data, *bitbuffer);
|
||||
stbi__sbpush(data, (unsigned char)*bitbuffer);
|
||||
*bitbuffer >>= 8;
|
||||
*bitcount -= 8;
|
||||
}
|
||||
@ -348,10 +348,10 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l
|
||||
j += blocklen;
|
||||
blocklen = 5552;
|
||||
}
|
||||
stbi__sbpush(out, s2 >> 8);
|
||||
stbi__sbpush(out, s2);
|
||||
stbi__sbpush(out, s1 >> 8);
|
||||
stbi__sbpush(out, s1);
|
||||
stbi__sbpush(out, (unsigned char)(s2 >> 8));
|
||||
stbi__sbpush(out, (unsigned char)s2);
|
||||
stbi__sbpush(out, (unsigned char)(s1 >> 8));
|
||||
stbi__sbpush(out, (unsigned char)s1);
|
||||
}
|
||||
*out_len = stbi__sbn(out);
|
||||
// make returned pointer freeable
|
||||
@ -362,7 +362,7 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l
|
||||
unsigned int stbi__crc32(unsigned char *buffer, int len)
|
||||
{
|
||||
static unsigned int crc_table[256];
|
||||
unsigned int crc = ~0;
|
||||
unsigned int crc = ~(unsigned int)0;
|
||||
int i,j;
|
||||
if (crc_table[1] == 0)
|
||||
for(i=0; i < 256; i++)
|
||||
@ -373,7 +373,7 @@ unsigned int stbi__crc32(unsigned char *buffer, int len)
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
#define stbi__wpng4(o,a,b,c,d) ((o)[0]=(a),(o)[1]=(b),(o)[2]=(c),(o)[3]=(d),(o)+=4)
|
||||
#define stbi__wpng4(o,a,b,c,d) ((o)[0]=(unsigned char)(a),(o)[1]=(unsigned char)(b),(o)[2]=(unsigned char)(c),(o)[3]=(unsigned char)(d),(o)+=4)
|
||||
#define stbi__wp32(data,v) stbi__wpng4(data, v>>24,v>>16,v>>8,v);
|
||||
#define stbi__wptag(data,s) stbi__wpng4(data, s[0],s[1],s[2],s[3])
|
||||
|
||||
@ -419,7 +419,7 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
||||
case 1: line_buffer[i] = z[i]; break;
|
||||
case 2: line_buffer[i] = z[i] - z[i-stride_bytes]; break;
|
||||
case 3: line_buffer[i] = z[i] - (z[i-stride_bytes]>>1); break;
|
||||
case 4: line_buffer[i] = z[i] - stbi__paeth(0,z[i-stride_bytes],0); break;
|
||||
case 4: line_buffer[i] = (signed char)(z[i] - stbi__paeth(0,z[i-stride_bytes],0)); break;
|
||||
case 5: line_buffer[i] = z[i]; break;
|
||||
case 6: line_buffer[i] = z[i]; break;
|
||||
}
|
||||
@ -429,9 +429,9 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
||||
case 1: line_buffer[i] = z[i] - z[i-n]; break;
|
||||
case 2: line_buffer[i] = z[i] - z[i-stride_bytes]; break;
|
||||
case 3: line_buffer[i] = z[i] - ((z[i-n] + z[i-stride_bytes])>>1); break;
|
||||
case 4: line_buffer[i] = z[i] - stbi__paeth(z[i-n], z[i-stride_bytes], z[i-stride_bytes-n]); break;
|
||||
case 4: line_buffer[i] = (signed char)(z[i] - stbi__paeth(z[i-n], z[i-stride_bytes], z[i-stride_bytes-n])); break;
|
||||
case 5: line_buffer[i] = z[i] - (z[i-n]>>1); break;
|
||||
case 6: line_buffer[i] = z[i] - stbi__paeth(z[i-n], 0,0); break;
|
||||
case 6: line_buffer[i] = (signed char)(z[i] - stbi__paeth(z[i-n], 0,0)); break;
|
||||
}
|
||||
}
|
||||
if (p) break;
|
||||
@ -441,7 +441,7 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
||||
}
|
||||
}
|
||||
// when we get here, best contains the filter type, and line_buffer contains the data
|
||||
filt[j*(x*n+1)] = best;
|
||||
filt[j*(x*n+1)] = (unsigned char)best;
|
||||
memcpy(filt+j*(x*n+1)+1, line_buffer, x*n);
|
||||
}
|
||||
free(line_buffer);
|
||||
@ -461,7 +461,7 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
||||
stbi__wp32(o, x);
|
||||
stbi__wp32(o, y);
|
||||
*o++ = 8;
|
||||
*o++ = ctype[n];
|
||||
*o++ = (unsigned char)ctype[n];
|
||||
*o++ = 0;
|
||||
*o++ = 0;
|
||||
*o++ = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user