fix compilation of stb_image_write.h with gcc -O3

When compiling with -O3, gcc would complain that 'linear' might not be
initialized if comp is superior to 4.

In fact passing a value > 4 is an error anyway, but gcc does not know
that.  I changed the switch case to support comp > 4.  I don't think it
should affect the performances.
pull/111/head
Guillaume Chereau 2015-04-20 22:59:24 +08:00
parent 947bdcd027
commit 347e7838be
1 changed files with 4 additions and 4 deletions

View File

@ -294,8 +294,8 @@ void stbiw__write_hdr_scanline(FILE *f, int width, int comp, unsigned char *scra
linear[1] = scanline[x*comp + 1];
linear[0] = scanline[x*comp + 0];
break;
case 2: /* fallthrough */
case 1: linear[0] = linear[1] = linear[2] = scanline[x*comp + 0];
default:
linear[0] = linear[1] = linear[2] = scanline[x*comp + 0];
break;
}
stbiw__linear_to_rgbe(rgbe, linear);
@ -311,8 +311,8 @@ void stbiw__write_hdr_scanline(FILE *f, int width, int comp, unsigned char *scra
linear[1] = scanline[x*comp + 1];
linear[0] = scanline[x*comp + 0];
break;
case 2: /* fallthrough */
case 1: linear[0] = linear[1] = linear[2] = scanline[x*comp + 0];
default:
linear[0] = linear[1] = linear[2] = scanline[x*comp + 0];
break;
}
stbiw__linear_to_rgbe(rgbe, linear);