image data load via STB


#define  STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
    :
int   lx, ly, bpp;
char  *raw=NULL;    // Initialization required
PIXEL **sour=NULL;  // Initialization required

    if( (raw=(char*)stbi_load( ifname, &lx, &ly, &bpp, 4 ))==NULL ) {
        fprintf(stderr,"Couldn't load the image '%s'.\n",ifname);  goto GOOD_BY;
    } else if( (sour=(PIXEL**)alloc2D( raw, sizeof(PIXEL), lx, ly ))==NULL ) {
        fprintf(stderr, "Couldn't allocate memory. source\n");     goto GOOD_BY;
    } else imageFittingOperation( sour, lx, ly );
    :
    saveArray2bmp32( "loaded_image.bmp", sour, lx, ly );
    :
GOOD_BY:; //Goodbye with doing the following process
    free(sour);
    stbi_image_free(raw);
}

void imageFittingOperation( PIXEL **s, int lx, int ly ) {
int   x, y, ey=(ly +1)/2, ty=ly-1;
PIXEL p;

    for( y=0; y<ey; y++ ) for( x=0; x<lx; x++ ) {
        p       = (PIXEL){ s[y][x].R, s[y][x].G, s[y][x].B, 0 };
        s[y][x] = (PIXEL){ s[ty-y][x].R, s[ty-y][x].G, s[ty-y][x].B, 0 };
        s[ty-y][x] = p;
    }// 色要素順の変更( B ⇔ R )及び 左上原点系 から 左下原点系への変換
}


diff: // stb_image - v2.19     (warning: unused parameter) ‘req_comp’‘ri’
  static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back)
< {
> {  (void)req_comp;

  static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
< {
> {  (void)ri;


diff: // stb_image - v2.26     (warning: comparison between signed and unsigned integer expressions)
<    if (b >= sizeof(z->size)) return -1; // some data was corrupt somewhere!
>    if ((long long)b >= (long long)sizeof(z->size)) return -1; // some data was corrupt somewhere!