mirror of https://github.com/nothings/stb.git
Fix GCC misleading-indentation warnings.
parent
e75ca4234e
commit
db236618d0
78
stb_image.h
78
stb_image.h
|
@ -1361,18 +1361,30 @@ static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int r
|
|||
// convert source image with img_n components to one with req_comp components;
|
||||
// avoid switch per pixel, so use switch per scanline and massive macros
|
||||
switch (COMBO(img_n, req_comp)) {
|
||||
CASE(1,2) dest[0]=src[0], dest[1]=255; break;
|
||||
CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break;
|
||||
CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break;
|
||||
CASE(2,1) dest[0]=src[0]; break;
|
||||
CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break;
|
||||
CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break;
|
||||
CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break;
|
||||
CASE(3,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break;
|
||||
CASE(3,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = 255; break;
|
||||
CASE(4,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break;
|
||||
CASE(4,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break;
|
||||
CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break;
|
||||
CASE(1,2) dest[0]=src[0], dest[1]=255;
|
||||
break;
|
||||
CASE(1,3) dest[0]=dest[1]=dest[2]=src[0];
|
||||
break;
|
||||
CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255;
|
||||
break;
|
||||
CASE(2,1) dest[0]=src[0];
|
||||
break;
|
||||
CASE(2,3) dest[0]=dest[1]=dest[2]=src[0];
|
||||
break;
|
||||
CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1];
|
||||
break;
|
||||
CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255;
|
||||
break;
|
||||
CASE(3,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]);
|
||||
break;
|
||||
CASE(3,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = 255;
|
||||
break;
|
||||
CASE(4,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]);
|
||||
break;
|
||||
CASE(4,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = src[3];
|
||||
break;
|
||||
CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2];
|
||||
break;
|
||||
default: STBI_ASSERT(0);
|
||||
}
|
||||
#undef CASE
|
||||
|
@ -4086,13 +4098,20 @@ static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 r
|
|||
for (k=0; k < nk; ++k)
|
||||
switch (filter) {
|
||||
// "none" filter turns into a memcpy here; make that explicit.
|
||||
case STBI__F_none: memcpy(cur, raw, nk); break;
|
||||
CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); break;
|
||||
CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break;
|
||||
CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); break;
|
||||
CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); break;
|
||||
CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); break;
|
||||
CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); break;
|
||||
case STBI__F_none: memcpy(cur, raw, nk);
|
||||
break;
|
||||
CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]);
|
||||
break;
|
||||
CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]);
|
||||
break;
|
||||
CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1));
|
||||
break;
|
||||
CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes]));
|
||||
break;
|
||||
CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1));
|
||||
break;
|
||||
CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0));
|
||||
break;
|
||||
}
|
||||
#undef CASE
|
||||
raw += nk;
|
||||
|
@ -4103,13 +4122,20 @@ static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 r
|
|||
for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \
|
||||
for (k=0; k < filter_bytes; ++k)
|
||||
switch (filter) {
|
||||
CASE(STBI__F_none) cur[k] = raw[k]; break;
|
||||
CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); break;
|
||||
CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break;
|
||||
CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); break;
|
||||
CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); break;
|
||||
CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); break;
|
||||
CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); break;
|
||||
CASE(STBI__F_none) cur[k] = raw[k];
|
||||
break;
|
||||
CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]);
|
||||
break;
|
||||
CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]);
|
||||
break;
|
||||
CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1));
|
||||
break;
|
||||
CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes]));
|
||||
break;
|
||||
CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1));
|
||||
break;
|
||||
CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0));
|
||||
break;
|
||||
}
|
||||
#undef CASE
|
||||
|
||||
|
|
Loading…
Reference in New Issue