changeset 768:71af31139e46

Use SDL types.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 09 May 2013 19:58:06 +0300
parents 339f6c95605c
children b87c7fc646f9 59df354b99cc
files stb_image.c
diffstat 1 files changed, 201 insertions(+), 211 deletions(-) [+]
line wrap: on
line diff
--- a/stb_image.c	Thu May 09 19:37:25 2013 +0300
+++ b/stb_image.c	Thu May 09 19:58:06 2013 +0300
@@ -28,7 +28,7 @@
       1.30 (2011-06-11) added ability to load files via io callbacks (Ben Wenger)
       1.29 (2010-08-16) various warning fixes from Aurelien Pocheville 
       1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ)
-      1.27 (2010-08-01) cast-to-uint8 to fix warnings (Laurent Gomila)
+      1.27 (2010-08-01) cast-to-Uint8 to fix warnings (Laurent Gomila)
                         allow trailing 0s at end of image data (Laurent Gomila)
       1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ
 
@@ -304,7 +304,7 @@
 
 // define faster low-level operations (typically SIMD support)
 #ifdef STBI_SIMD
-typedef void (*stbi_idct_8x8)(stbi_uc *out, int out_stride, short data[64], unsigned short *dequantize);
+typedef void (*stbi_idct_8x8)(stbi_uc *out, int out_stride, Sint16 data[64], Uint16 *dequantize);
 // compute an integer IDCT on "input"
 //     input[x] = data[x] * dequantize[x]
 //     write results to 'out': 64 samples, each run of 8 spaced by 'out_stride'
@@ -356,17 +356,7 @@
    #define stbi_inline __forceinline
 #endif
 
-
-// implementation:
-typedef unsigned char  uint8;
-typedef unsigned short uint16;
-typedef   signed short  int16;
-typedef unsigned int   uint32;
-typedef   signed int    int32;
-typedef unsigned int   uint;
-
-// should produce compiler error if size is wrong
-typedef unsigned char validate_uint32[sizeof(uint32)==4 ? 1 : -1];
+typedef unsigned int Uint;
 
 #if defined(STBI_NO_STDIO) && !defined(STBI_NO_WRITE)
 #define STBI_NO_WRITE
@@ -392,7 +382,7 @@
 // contains all the IO context, plus some basic image information
 typedef struct
 {
-   uint32 img_x, img_y;
+   Uint32 img_x, img_y;
    int img_n, img_out_n;
    
    stbi_io_callbacks io;
@@ -400,22 +390,22 @@
 
    int read_from_callbacks;
    int buflen;
-   uint8 buffer_start[128];
-
-   uint8 *img_buffer, *img_buffer_end;
-   uint8 *img_buffer_original;
+   Uint8 buffer_start[128];
+
+   Uint8 *img_buffer, *img_buffer_end;
+   Uint8 *img_buffer_original;
 } stbi;
 
 
 static void refill_buffer(stbi *s);
 
 // initialize a memory-decode context
-static void start_mem(stbi *s, uint8 const *buffer, int len)
+static void start_mem(stbi *s, Uint8 const *buffer, int len)
 {
    s->io.read = NULL;
    s->read_from_callbacks = 0;
-   s->img_buffer = s->img_buffer_original = (uint8 *) buffer;
-   s->img_buffer_end = (uint8 *) buffer+len;
+   s->img_buffer = s->img_buffer_original = (Uint8 *) buffer;
+   s->img_buffer_end = (Uint8 *) buffer+len;
 }
 
 // initialize a callback-based context
@@ -760,9 +750,9 @@
    return s->img_buffer >= s->img_buffer_end;   
 }
 
-stbi_inline static uint8 get8u(stbi *s)
+stbi_inline static Uint8 get8u(stbi *s)
 {
-   return (uint8) get8(s);
+   return (Uint8) get8(s);
 }
 
 static void skip(stbi *s, int n)
@@ -808,9 +798,9 @@
    return (z << 8) + get8(s);
 }
 
-static uint32 get32(stbi *s)
+static Uint32 get32(stbi *s)
 {
-   uint32 z = get16(s);
+   Uint32 z = get16(s);
    return (z << 16) + get16(s);
 }
 
@@ -821,9 +811,9 @@
    return z + (get8(s) << 8);
 }
 
-static uint32 get32le(stbi *s)
+static Uint32 get32le(stbi *s)
 {
-   uint32 z = get16le(s);
+   Uint32 z = get16le(s);
    return z + (get16le(s) << 16);
 }
 #endif
@@ -839,12 +829,12 @@
 //  assume data buffer is malloced, so malloc a new one and free that one
 //  only failure mode is malloc failing
 
-static uint8 compute_y(int r, int g, int b)
+static Uint8 compute_y(int r, int g, int b)
 {
-   return (uint8) (((r*77) + (g*150) +  (29*b)) >> 8);
+   return (Uint8) (((r*77) + (g*150) +  (29*b)) >> 8);
 }
 
-static unsigned char *convert_format(unsigned char *data, int img_n, int req_comp, uint x, uint y)
+static unsigned char *convert_format(unsigned char *data, int img_n, int req_comp, Uint x, Uint y)
 {
    int i,j;
    unsigned char *good;
@@ -919,13 +909,13 @@
          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] = (uint8) float2int(z);
+         output[i*comp + k] = (Uint8) 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] = (uint8) float2int(z);
+         output[i*comp + k] = (Uint8) float2int(z);
       }
    }
    free(data);
@@ -965,11 +955,11 @@
 
 typedef struct
 {
-   uint8  fast[1 << FAST_BITS];
+   Uint8  fast[1 << FAST_BITS];
    // weirdly, repacking this into AoS is a 10% speed loss, instead of a win
-   uint16 code[256];
-   uint8  values[256];
-   uint8  size[257];
+   Uint16 code[256];
+   Uint8  values[256];
+   Uint8  size[257];
    unsigned int maxcode[18];
    int    delta[17];   // old 'firstsymbol' - old 'firstcode'
 } huffman;
@@ -977,12 +967,12 @@
 typedef struct
 {
    #ifdef STBI_SIMD
-   unsigned short dequant2[4][64];
+   Uint16 dequant2[4][64];
    #endif
    stbi *s;
    huffman huff_dc[4];
    huffman huff_ac[4];
-   uint8 dequant[4][64];
+   Uint8 dequant[4][64];
 
 // sizes for components, interleaved MCUs
    int img_h_max, img_v_max;
@@ -999,12 +989,12 @@
       int dc_pred;
 
       int x,y,w2,h2;
-      uint8 *data;
+      Uint8 *data;
       void *raw_data;
-      uint8 *linebuf;
+      Uint8 *linebuf;
    } img_comp[4];
 
-   uint32         code_buffer; // jpeg entropy-coded buffer
+   Uint32         code_buffer; // jpeg entropy-coded buffer
    int            code_bits;   // number of valid bits
    unsigned char  marker;      // marker seen while filling entropy buffer
    int            nomore;      // flag if we saw a marker so must stop
@@ -1019,7 +1009,7 @@
    // build size list for each symbol (from JPEG spec)
    for (i=0; i < 16; ++i)
       for (j=0; j < count[i]; ++j)
-         h->size[k++] = (uint8) (i+1);
+         h->size[k++] = (Uint8) (i+1);
    h->size[k] = 0;
 
    // compute actual symbols (from jpeg spec)
@@ -1030,7 +1020,7 @@
       h->delta[j] = k - code;
       if (h->size[k] == j) {
          while (h->size[k] == j)
-            h->code[k++] = (uint16) (code++);
+            h->code[k++] = (Uint16) (code++);
          if (code-1 >= (1 << j)) return e("bad code lengths","Corrupt JPEG");
       }
       // compute largest code + 1 for this size, preshifted as needed later
@@ -1047,7 +1037,7 @@
          int c = h->code[i] << (FAST_BITS-s);
          int m = 1 << (FAST_BITS-s);
          for (j=0; j < m; ++j) {
-            h->fast[c+j] = (uint8) i;
+            h->fast[c+j] = (Uint8) i;
          }
       }
    }
@@ -1072,7 +1062,7 @@
 }
 
 // (1 << n) - 1
-static uint32 bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
+static Uint32 bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
 
 // decode a jpeg huffman value from the bitstream
 stbi_inline static int decode(jpeg *j, huffman *h)
@@ -1153,7 +1143,7 @@
 
 // given a value that's at position X in the zigzag stream,
 // where does it appear in the 8x8 matrix coded as row-major?
-static uint8 dezigzag[64+15] =
+static Uint8 dezigzag[64+15] =
 {
     0,  1,  8, 16,  9,  2,  3, 10,
    17, 24, 32, 25, 18, 11,  4,  5,
@@ -1169,7 +1159,7 @@
 };
 
 // decode one 64-entry block--
-static int decode_block(jpeg *j, short data[64], huffman *hdc, huffman *hac, int b)
+static int decode_block(jpeg *j, Sint16 data[64], huffman *hdc, huffman *hac, int b)
 {
    int diff,dc,k;
    int t = decode(j, hdc);
@@ -1181,7 +1171,7 @@
    diff = t ? extend_receive(j, t) : 0;
    dc = j->img_comp[b].dc_pred + diff;
    j->img_comp[b].dc_pred = dc;
-   data[0] = (short) dc;
+   data[0] = (Sint16) dc;
 
    // decode AC components, see JPEG spec
    k = 1;
@@ -1197,21 +1187,21 @@
       } else {
          k += r;
          // decode into unzigzag'd location
-         data[dezigzag[k++]] = (short) extend_receive(j,s);
+         data[dezigzag[k++]] = (Sint16) extend_receive(j,s);
       }
    } while (k < 64);
    return 1;
 }
 
 // take a -128..127 value and clamp it and convert to 0..255
-stbi_inline static uint8 clamp(int x)
+stbi_inline static Uint8 clamp(int x)
 {
    // trick to use a single test to catch both cases
    if ((unsigned int) x > 255) {
       if (x < 0) return 0;
       if (x > 255) return 255;
    }
-   return (uint8) x;
+   return (Uint8) x;
 }
 
 #define f2f(x)  (int) (((x) * 4096 + 0.5))
@@ -1256,18 +1246,18 @@
    t0 += p1+p3;
 
 #ifdef STBI_SIMD
-typedef unsigned short stbi_dequantize_t;
+typedef Uint16 stbi_dequantize_t;
 #else
-typedef uint8 stbi_dequantize_t;
+typedef Uint8 stbi_dequantize_t;
 #endif
 
 // .344 seconds on 3*anemones.jpg
-static void idct_block(uint8 *out, int out_stride, short data[64], stbi_dequantize_t *dequantize)
+static void idct_block(Uint8 *out, int out_stride, Sint16 data[64], stbi_dequantize_t *dequantize)
 {
    int i,val[64],*v=val;
    stbi_dequantize_t *dq = dequantize;
-   uint8 *o;
-   short *d = data;
+   Uint8 *o;
+   Sint16 *d = data;
 
    // columns
    for (i=0; i < 8; ++i,++d,++dq, ++v) {
@@ -1336,9 +1326,9 @@
 // if there's a pending marker from the entropy stream, return that
 // otherwise, fetch from the stream and get a marker. if there's no
 // marker, return 0xff, which is never a valid marker value
-static uint8 get_marker(jpeg *j)
+static Uint8 get_marker(jpeg *j)
 {
-   uint8 x;
+   Uint8 x;
    if (j->marker != MARKER_none) { x = j->marker; j->marker = MARKER_none; return x; }
    x = get8u(j->s);
    if (x != 0xff) return MARKER_none;
@@ -1373,7 +1363,7 @@
       #ifdef STBI_SIMD
       __declspec(align(16))
       #endif
-      short data[64];
+      Sint16 data[64];
       int n = z->order[0];
       // non-interleaved data, we just need to process one block at a time,
       // in trivial scanline order
@@ -1401,7 +1391,7 @@
       }
    } else { // interleaved!
       int i,j,k,x,y;
-      short data[64];
+      Sint16 data[64];
       for (j=0; j < z->img_mcu_y; ++j) {
          for (i=0; i < z->img_mcu_x; ++i) {
             // scan an interleaved mcu... process scan_n components in order
@@ -1473,7 +1463,7 @@
       case 0xC4: // DHT - define huffman table
          L = get16(z->s)-2;
          while (L > 0) {
-            uint8 *v;
+            Uint8 *v;
             int sizes[16],i,m=0;
             int q = get8(z->s);
             int tc = q >> 4;
@@ -1596,7 +1586,7 @@
          return e("outofmem", "Out of memory");
       }
       // align blocks for installable-idct using mmx/sse
-      z->img_comp[i].data = (uint8*) (((size_t) z->img_comp[i].raw_data + 15) & ~15);
+      z->img_comp[i].data = (Uint8*) (((size_t) z->img_comp[i].raw_data + 15) & ~15);
       z->img_comp[i].linebuf = NULL;
    }
 
@@ -1664,12 +1654,12 @@
 
 // static jfif-centered resampling (across block boundaries)
 
-typedef uint8 *(*resample_row_func)(uint8 *out, uint8 *in0, uint8 *in1,
+typedef Uint8 *(*resample_row_func)(Uint8 *out, Uint8 *in0, Uint8 *in1,
                                     int w, int hs);
 
-#define div4(x) ((uint8) ((x) >> 2))
-
-static uint8 *resample_row_1(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs)
+#define div4(x) ((Uint8) ((x) >> 2))
+
+static Uint8 *resample_row_1(Uint8 *out, Uint8 *in_near, Uint8 *in_far, int w, int hs)
 {
    STBI_NOTUSED(out);
    STBI_NOTUSED(in_far);
@@ -1678,7 +1668,7 @@
    return in_near;
 }
 
-static uint8* resample_row_v_2(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs)
+static Uint8* resample_row_v_2(Uint8 *out, Uint8 *in_near, Uint8 *in_far, int w, int hs)
 {
    // need to generate two samples vertically for every one in input
    int i;
@@ -1688,11 +1678,11 @@
    return out;
 }
 
-static uint8*  resample_row_h_2(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs)
+static Uint8*  resample_row_h_2(Uint8 *out, Uint8 *in_near, Uint8 *in_far, int w, int hs)
 {
    // need to generate two samples horizontally for every one in input
    int i;
-   uint8 *input = in_near;
+   Uint8 *input = in_near;
 
    if (w == 1) {
       // if only one sample, can't do any interpolation
@@ -1716,9 +1706,9 @@
    return out;
 }
 
-#define div16(x) ((uint8) ((x) >> 4))
-
-static uint8 *resample_row_hv_2(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs)
+#define div16(x) ((Uint8) ((x) >> 4))
+
+static Uint8 *resample_row_hv_2(Uint8 *out, Uint8 *in_near, Uint8 *in_far, int w, int hs)
 {
    // need to generate 2x2 samples for every one in input
    int i,t0,t1;
@@ -1742,7 +1732,7 @@
    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;
@@ -1757,7 +1747,7 @@
 
 // 0.38 seconds on 3*anemones.jpg   (0.25 with processor = Pro)
 // VC6 without processor=Pro is generating multiple LEAs per multiply!
-static void YCbCr_to_RGB_row(uint8 *out, const uint8 *y, const uint8 *pcb, const uint8 *pcr, int count, int step)
+static void YCbCr_to_RGB_row(Uint8 *out, const Uint8 *y, const Uint8 *pcb, const Uint8 *pcr, int count, int step)
 {
    int i;
    for (i=0; i < count; ++i) {
@@ -1774,9 +1764,9 @@
       if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; }
       if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; }
       if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; }
-      out[0] = (uint8)r;
-      out[1] = (uint8)g;
-      out[2] = (uint8)b;
+      out[0] = (Uint8)r;
+      out[1] = (Uint8)g;
+      out[2] = (Uint8)b;
       out[3] = 255;
       out += step;
    }
@@ -1811,14 +1801,14 @@
 typedef struct
 {
    resample_row_func resample;
-   uint8 *line0,*line1;
+   Uint8 *line0,*line1;
    int hs,vs;   // expansion factor in each axis
    int w_lores; // horizontal pixels pre-expansion 
    int ystep;   // how far through vertical expansion we are
    int ypos;    // which pre-expansion row we're on
 } stbi_resample;
 
-static uint8 *load_jpeg_image(jpeg *z, int *out_x, int *out_y, int *comp, int req_comp)
+static Uint8 *load_jpeg_image(jpeg *z, int *out_x, int *out_y, int *comp, int req_comp)
 {
    int n, decode_n;
    // validate req_comp
@@ -1839,9 +1829,9 @@
    // resample and color-convert
    {
       int k;
-      uint i,j;
-      uint8 *output;
-      uint8 *coutput[4];
+      Uint i,j;
+      Uint8 *output;
+      Uint8 *coutput[4];
 
       stbi_resample res_comp[4];
 
@@ -1850,7 +1840,7 @@
 
          // allocate line buffer big enough for upsampling off the edges
          // with upsample factor of 4
-         z->img_comp[k].linebuf = (uint8 *) malloc(z->s->img_x + 3);
+         z->img_comp[k].linebuf = (Uint8 *) malloc(z->s->img_x + 3);
          if (!z->img_comp[k].linebuf) { cleanup_jpeg(z); return epuc("outofmem", "Out of memory"); }
 
          r->hs      = z->img_h_max / z->img_comp[k].h;
@@ -1868,12 +1858,12 @@
       }
 
       // can't error after this so, this is safe
-      output = (uint8 *) malloc(n * z->s->img_x * z->s->img_y + 1);
+      output = (Uint8 *) malloc(n * z->s->img_x * z->s->img_y + 1);
       if (!output) { cleanup_jpeg(z); return epuc("outofmem", "Out of memory"); }
 
       // now go ahead and resample
       for (j=0; j < z->s->img_y; ++j) {
-         uint8 *out = output + n * z->s->img_x * j;
+         Uint8 *out = output + n * z->s->img_x * j;
          for (k=0; k < decode_n; ++k) {
             stbi_resample *r = &res_comp[k];
             int y_bot = r->ystep >= (r->vs >> 1);
@@ -1889,7 +1879,7 @@
             }
          }
          if (n >= 3) {
-            uint8 *y = coutput[0];
+            Uint8 *y = coutput[0];
             if (z->s->img_n == 3) {
                #ifdef STBI_SIMD
                stbi_YCbCr_installed(out, y, coutput[1], coutput[2], z->s.img_x, n);
@@ -1903,7 +1893,7 @@
                   out += n;
                }
          } else {
-            uint8 *y = coutput[0];
+            Uint8 *y = coutput[0];
             if (n == 1)
                for (i=0; i < z->s->img_x; ++i) out[i] = y[i];
             else
@@ -1969,12 +1959,12 @@
 // (jpegs packs from left, zlib from right, so can't share code)
 typedef struct
 {
-   uint16 fast[1 << ZFAST_BITS];
-   uint16 firstcode[16];
+   Uint16 fast[1 << ZFAST_BITS];
+   Uint16 firstcode[16];
    int maxcode[17];
-   uint16 firstsymbol[16];
-   uint8  size[288];
-   uint16 value[288]; 
+   Uint16 firstsymbol[16];
+   Uint8  size[288];
+   Uint16 value[288]; 
 } zhuffman;
 
 stbi_inline static int bitreverse16(int n)
@@ -1994,7 +1984,7 @@
    return bitreverse16(v) >> (16-bits);
 }
 
-static int zbuild_huffman(zhuffman *z, uint8 *sizelist, int num)
+static int zbuild_huffman(zhuffman *z, Uint8 *sizelist, int num)
 {
    int i,k=0;
    int code, next_code[16], sizes[17];
@@ -2010,8 +2000,8 @@
    code = 0;
    for (i=1; i < 16; ++i) {
       next_code[i] = code;
-      z->firstcode[i] = (uint16) code;
-      z->firstsymbol[i] = (uint16) k;
+      z->firstcode[i] = (Uint16) code;
+      z->firstsymbol[i] = (Uint16) k;
       code = (code + sizes[i]);
       if (sizes[i])
          if (code-1 >= (1 << i)) return e("bad codelengths","Corrupt JPEG");
@@ -2024,12 +2014,12 @@
       int s = sizelist[i];
       if (s) {
          int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s];
-         z->size[c] = (uint8)s;
-         z->value[c] = (uint16)i;
+         z->size[c] = (Uint8)s;
+         z->value[c] = (Uint16)i;
          if (s <= ZFAST_BITS) {
             int k = bit_reverse(next_code[s],s);
             while (k < (1 << ZFAST_BITS)) {
-               z->fast[k] = (uint16) c;
+               z->fast[k] = (Uint16) c;
                k += (1 << s);
             }
          }
@@ -2047,9 +2037,9 @@
 
 typedef struct
 {
-   uint8 *zbuffer, *zbuffer_end;
+   Uint8 *zbuffer, *zbuffer_end;
    int num_bits;
-   uint32 code_buffer;
+   Uint32 code_buffer;
 
    char *zout;
    char *zout_start;
@@ -2151,7 +2141,7 @@
          if (a->zout >= a->zout_end) if (!expand(a, 1)) return 0;
          *a->zout++ = (char) z;
       } else {
-         uint8 *p;
+         Uint8 *p;
          int len,dist;
          if (z == 256) return 1;
          z -= 257;
@@ -2163,7 +2153,7 @@
          if (dist_extra[z]) dist += zreceive(a, dist_extra[z]);
          if (a->zout - a->zout_start < dist) return e("bad dist","Corrupt PNG");
          if (a->zout + len > a->zout_end) if (!expand(a, len)) return 0;
-         p = (uint8 *) (a->zout - dist);
+         p = (Uint8 *) (a->zout - dist);
          while (len--)
             *a->zout++ = *p++;
       }
@@ -2172,10 +2162,10 @@
 
 static int compute_huffman_codes(zbuf *a)
 {
-   static uint8 length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 };
+   static Uint8 length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 };
    zhuffman z_codelength;
-   uint8 lencodes[286+32+137];//padding for maximum single op
-   uint8 codelength_sizes[19];
+   Uint8 lencodes[286+32+137];//padding for maximum single op
+   Uint8 codelength_sizes[19];
    int i,n;
 
    int hlit  = zreceive(a,5) + 257;
@@ -2185,7 +2175,7 @@
    memset(codelength_sizes, 0, sizeof(codelength_sizes));
    for (i=0; i < hclen; ++i) {
       int s = zreceive(a,3);
-      codelength_sizes[length_dezigzag[i]] = (uint8) s;
+      codelength_sizes[length_dezigzag[i]] = (Uint8) s;
    }
    if (!zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0;
 
@@ -2194,7 +2184,7 @@
       int c = zhuffman_decode(a, &z_codelength);
       assert(c >= 0 && c < 19);
       if (c < 16)
-         lencodes[n++] = (uint8) c;
+         lencodes[n++] = (Uint8) c;
       else if (c == 16) {
          c = zreceive(a,2)+3;
          memset(lencodes+n, lencodes[n-1], c);
@@ -2218,21 +2208,21 @@
 
 static int parse_uncompressed_block(zbuf *a)
 {
-   uint8 header[4];
+   Uint8 header[4];
    int len,nlen,k;
    if (a->num_bits & 7)
       zreceive(a, a->num_bits & 7); // discard
    // drain the bit-packed data into header
    k = 0;
    while (a->num_bits > 0) {
-      header[k++] = (uint8) (a->code_buffer & 255); // wtf this warns?
+      header[k++] = (Uint8) (a->code_buffer & 255); // wtf this warns?
       a->code_buffer >>= 8;
       a->num_bits -= 8;
    }
    assert(a->num_bits == 0);
    // now fill header the normal way
    while (k < 4)
-      header[k++] = (uint8) zget8(a);
+      header[k++] = (Uint8) zget8(a);
    len  = header[1] * 256 + header[0];
    nlen = header[3] * 256 + header[2];
    if (nlen != (len ^ 0xffff)) return e("zlib corrupt","Corrupt PNG");
@@ -2259,7 +2249,7 @@
 }
 
 // @TODO: should statically initialize these for optimal thread safety
-static uint8 default_length[288], default_distance[32];
+static Uint8 default_length[288], default_distance[32];
 static void init_defaults(void)
 {
    int i;   // use <= to match clearly with spec
@@ -2318,8 +2308,8 @@
    zbuf a;
    char *p = (char *) malloc(initial_size);
    if (p == NULL) return NULL;
-   a.zbuffer = (uint8 *) buffer;
-   a.zbuffer_end = (uint8 *) buffer + len;
+   a.zbuffer = (Uint8 *) buffer;
+   a.zbuffer_end = (Uint8 *) buffer + len;
    if (do_zlib(&a, p, initial_size, 1, 1)) {
       if (outlen) *outlen = (int) (a.zout - a.zout_start);
       return a.zout_start;
@@ -2339,8 +2329,8 @@
    zbuf a;
    char *p = (char *) malloc(initial_size);
    if (p == NULL) return NULL;
-   a.zbuffer = (uint8 *) buffer;
-   a.zbuffer_end = (uint8 *) buffer + len;
+   a.zbuffer = (Uint8 *) buffer;
+   a.zbuffer_end = (Uint8 *) buffer + len;
    if (do_zlib(&a, p, initial_size, 1, parse_header)) {
       if (outlen) *outlen = (int) (a.zout - a.zout_start);
       return a.zout_start;
@@ -2353,8 +2343,8 @@
 int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen)
 {
    zbuf a;
-   a.zbuffer = (uint8 *) ibuffer;
-   a.zbuffer_end = (uint8 *) ibuffer + ilen;
+   a.zbuffer = (Uint8 *) ibuffer;
+   a.zbuffer_end = (Uint8 *) ibuffer + ilen;
    if (do_zlib(&a, obuffer, olen, 0, 1))
       return (int) (a.zout - a.zout_start);
    else
@@ -2366,8 +2356,8 @@
    zbuf a;
    char *p = (char *) malloc(16384);
    if (p == NULL) return NULL;
-   a.zbuffer = (uint8 *) buffer;
-   a.zbuffer_end = (uint8 *) buffer+len;
+   a.zbuffer = (Uint8 *) buffer;
+   a.zbuffer_end = (Uint8 *) buffer+len;
    if (do_zlib(&a, p, 16384, 1, 0)) {
       if (outlen) *outlen = (int) (a.zout - a.zout_start);
       return a.zout_start;
@@ -2380,8 +2370,8 @@
 int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen)
 {
    zbuf a;
-   a.zbuffer = (uint8 *) ibuffer;
-   a.zbuffer_end = (uint8 *) ibuffer + ilen;
+   a.zbuffer = (Uint8 *) ibuffer;
+   a.zbuffer_end = (Uint8 *) ibuffer + ilen;
    if (do_zlib(&a, obuffer, olen, 0, 0))
       return (int) (a.zout - a.zout_start);
    else
@@ -2401,8 +2391,8 @@
 
 typedef struct
 {
-   uint32 length;
-   uint32 type;
+   Uint32 length;
+   Uint32 type;
 } chunk;
 
 #define PNG_TYPE(a,b,c,d)  (((a) << 24) + ((b) << 16) + ((c) << 8) + (d))
@@ -2417,7 +2407,7 @@
 
 static int check_png_header(stbi *s)
 {
-   static uint8 png_sig[8] = { 137,80,78,71,13,10,26,10 };
+   static Uint8 png_sig[8] = { 137,80,78,71,13,10,26,10 };
    int i;
    for (i=0; i < 8; ++i)
       if (get8u(s) != png_sig[i]) return e("bad png sig","Not a PNG");
@@ -2427,7 +2417,7 @@
 typedef struct
 {
    stbi *s;
-   uint8 *idata, *expanded, *out;
+   Uint8 *idata, *expanded, *out;
 } png;
 
 
@@ -2436,7 +2426,7 @@
    F_avg_first, F_paeth_first
 };
 
-static uint8 first_row_filter[5] =
+static Uint8 first_row_filter[5] =
 {
    F_none, F_sub, F_none, F_avg_first, F_paeth_first
 };
@@ -2453,15 +2443,15 @@
 }
 
 // create the png data from post-deflated data
-static int create_png_image_raw(png *a, uint8 *raw, uint32 raw_len, int out_n, uint32 x, uint32 y)
+static int create_png_image_raw(png *a, Uint8 *raw, Uint32 raw_len, int out_n, Uint32 x, Uint32 y)
 {
    stbi *s = a->s;
-   uint32 i,j,stride = x*out_n;
+   Uint32 i,j,stride = x*out_n;
    int k;
    int img_n = s->img_n; // copy it into a local for later
    assert(out_n == s->img_n || out_n == s->img_n+1);
    if (stbi_png_partial) y = 1;
-   a->out = (uint8 *) malloc(x * y * out_n);
+   a->out = (Uint8 *) malloc(x * y * out_n);
    if (!a->out) return e("outofmem", "Out of memory");
    if (!stbi_png_partial) {
       if (s->img_x == x && s->img_y == y) {
@@ -2471,8 +2461,8 @@
       }
    }
    for (j=0; j < y; ++j) {
-      uint8 *cur = a->out + stride*j;
-      uint8 *prior = cur - stride;
+      Uint8 *cur = a->out + stride*j;
+      Uint8 *prior = cur - stride;
       int filter = *raw++;
       if (filter > 4) return e("invalid filter","Corrupt PNG");
       // if first row, use special filter that doesn't sample previous row
@@ -2484,7 +2474,7 @@
             case F_sub        : cur[k] = raw[k]; break;
             case F_up         : cur[k] = raw[k] + prior[k]; break;
             case F_avg        : cur[k] = raw[k] + (prior[k]>>1); break;
-            case F_paeth      : cur[k] = (uint8) (raw[k] + paeth(0,prior[k],0)); break;
+            case F_paeth      : cur[k] = (Uint8) (raw[k] + paeth(0,prior[k],0)); break;
             case F_avg_first  : cur[k] = raw[k]; break;
             case F_paeth_first: cur[k] = raw[k]; break;
          }
@@ -2504,9 +2494,9 @@
             CASE(F_sub)   cur[k] = raw[k] + cur[k-img_n]; break;
             CASE(F_up)    cur[k] = raw[k] + prior[k]; break;
             CASE(F_avg)   cur[k] = raw[k] + ((prior[k] + cur[k-img_n])>>1); break;
-            CASE(F_paeth)  cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],prior[k],prior[k-img_n])); break;
+            CASE(F_paeth)  cur[k] = (Uint8) (raw[k] + paeth(cur[k-img_n],prior[k],prior[k-img_n])); break;
             CASE(F_avg_first)    cur[k] = raw[k] + (cur[k-img_n] >> 1); break;
-            CASE(F_paeth_first)  cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],0,0)); break;
+            CASE(F_paeth_first)  cur[k] = (Uint8) (raw[k] + paeth(cur[k-img_n],0,0)); break;
          }
          #undef CASE
       } else {
@@ -2520,9 +2510,9 @@
             CASE(F_sub)   cur[k] = raw[k] + cur[k-out_n]; break;
             CASE(F_up)    cur[k] = raw[k] + prior[k]; break;
             CASE(F_avg)   cur[k] = raw[k] + ((prior[k] + cur[k-out_n])>>1); break;
-            CASE(F_paeth)  cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],prior[k],prior[k-out_n])); break;
+            CASE(F_paeth)  cur[k] = (Uint8) (raw[k] + paeth(cur[k-out_n],prior[k],prior[k-out_n])); break;
             CASE(F_avg_first)    cur[k] = raw[k] + (cur[k-out_n] >> 1); break;
-            CASE(F_paeth_first)  cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],0,0)); break;
+            CASE(F_paeth_first)  cur[k] = (Uint8) (raw[k] + paeth(cur[k-out_n],0,0)); break;
          }
          #undef CASE
       }
@@ -2530,9 +2520,9 @@
    return 1;
 }
 
-static int create_png_image(png *a, uint8 *raw, uint32 raw_len, int out_n, int interlaced)
+static int create_png_image(png *a, Uint8 *raw, Uint32 raw_len, int out_n, int interlaced)
 {
-   uint8 *final;
+   Uint8 *final;
    int p;
    int save;
    if (!interlaced)
@@ -2541,7 +2531,7 @@
    stbi_png_partial = 0;
 
    // de-interlacing
-   final = (uint8 *) malloc(a->s->img_x * a->s->img_y * out_n);
+   final = (Uint8 *) malloc(a->s->img_x * a->s->img_y * out_n);
    for (p=0; p < 7; ++p) {
       int xorig[] = { 0,4,0,2,0,1,0 };
       int yorig[] = { 0,0,4,0,2,0,1 };
@@ -2571,11 +2561,11 @@
    return 1;
 }
 
-static int compute_transparency(png *z, uint8 tc[3], int out_n)
+static int compute_transparency(png *z, Uint8 tc[3], int out_n)
 {
    stbi *s = z->s;
-   uint32 i, pixel_count = s->img_x * s->img_y;
-   uint8 *p = z->out;
+   Uint32 i, pixel_count = s->img_x * s->img_y;
+   Uint8 *p = z->out;
 
    // compute color-based transparency, assuming we've
    // already got 255 as the alpha value in the output
@@ -2596,12 +2586,12 @@
    return 1;
 }
 
-static int expand_palette(png *a, uint8 *palette, int len, int pal_img_n)
+static int expand_palette(png *a, Uint8 *palette, int len, int pal_img_n)
 {
-   uint32 i, pixel_count = a->s->img_x * a->s->img_y;
-   uint8 *p, *temp_out, *orig = a->out;
-
-   p = (uint8 *) malloc(pixel_count * pal_img_n);
+   Uint32 i, pixel_count = a->s->img_x * a->s->img_y;
+   Uint8 *p, *temp_out, *orig = a->out;
+
+   p = (Uint8 *) malloc(pixel_count * pal_img_n);
    if (p == NULL) return e("outofmem", "Out of memory");
 
    // between here and free(out) below, exitting would leak
@@ -2648,12 +2638,12 @@
 static void stbi_de_iphone(png *z)
 {
    stbi *s = z->s;
-   uint32 i, pixel_count = s->img_x * s->img_y;
-   uint8 *p = z->out;
+   Uint32 i, pixel_count = s->img_x * s->img_y;
+   Uint8 *p = z->out;
 
    if (s->img_out_n == 3) {  // convert bgr to rgb
       for (i=0; i < pixel_count; ++i) {
-         uint8 t = p[0];
+         Uint8 t = p[0];
          p[0] = p[2];
          p[2] = t;
          p += 3;
@@ -2663,8 +2653,8 @@
       if (stbi_unpremultiply_on_load) {
          // convert bgr to rgb and unpremultiply
          for (i=0; i < pixel_count; ++i) {
-            uint8 a = p[3];
-            uint8 t = p[0];
+            Uint8 a = p[3];
+            Uint8 t = p[0];
             if (a) {
                p[0] = p[2] * 255 / a;
                p[1] = p[1] * 255 / a;
@@ -2678,7 +2668,7 @@
       } else {
          // convert bgr to rgb
          for (i=0; i < pixel_count; ++i) {
-            uint8 t = p[0];
+            Uint8 t = p[0];
             p[0] = p[2];
             p[2] = t;
             p += 4;
@@ -2689,9 +2679,9 @@
 
 static int parse_png_file(png *z, int scan, int req_comp)
 {
-   uint8 palette[1024], pal_img_n=0;
-   uint8 has_trans=0, tc[3];
-   uint32 ioff=0, idata_limit=0, i, pal_len=0;
+   Uint8 palette[1024], pal_img_n=0;
+   Uint8 has_trans=0, tc[3];
+   Uint32 ioff=0, idata_limit=0, i, pal_len=0;
    int first=1,k,interlace=0, iphone=0;
    stbi *s = z->s;
 
@@ -2764,10 +2754,10 @@
                   palette[i*4+3] = get8u(s);
             } else {
                if (!(s->img_n & 1)) return e("tRNS with alpha","Corrupt PNG");
-               if (c.length != (uint32) s->img_n*2) return e("bad tRNS len","Corrupt PNG");
+               if (c.length != (Uint32) s->img_n*2) return e("bad tRNS len","Corrupt PNG");
                has_trans = 1;
                for (k=0; k < s->img_n; ++k)
-                  tc[k] = (uint8) get16(s); // non 8-bit images will be larger
+                  tc[k] = (Uint8) get16(s); // non 8-bit images will be larger
             }
             break;
          }
@@ -2777,11 +2767,11 @@
             if (pal_img_n && !pal_len) return e("no PLTE","Corrupt PNG");
             if (scan == SCAN_header) { s->img_n = pal_img_n; return 1; }
             if (ioff + c.length > idata_limit) {
-               uint8 *p;
+               Uint8 *p;
                if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096;
                while (ioff + c.length > idata_limit)
                   idata_limit *= 2;
-               p = (uint8 *) realloc(z->idata, idata_limit); if (p == NULL) return e("outofmem", "Out of memory");
+               p = (Uint8 *) realloc(z->idata, idata_limit); if (p == NULL) return e("outofmem", "Out of memory");
                z->idata = p;
             }
             if (!getn(s, z->idata+ioff,c.length)) return e("outofdata","Corrupt PNG");
@@ -2790,11 +2780,11 @@
          }
 
          case PNG_TYPE('I','E','N','D'): {
-            uint32 raw_len;
+            Uint32 raw_len;
             if (first) return e("first not IHDR", "Corrupt PNG");
             if (scan != SCAN_load) return 1;
             if (z->idata == NULL) return e("no IDAT","Corrupt PNG");
-            z->expanded = (uint8 *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, 16384, (int *) &raw_len, !iphone);
+            z->expanded = (Uint8 *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, 16384, (int *) &raw_len, !iphone);
             if (z->expanded == NULL) return 0; // zlib should set error
             free(z->idata); z->idata = NULL;
             if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans)
@@ -2825,10 +2815,10 @@
                #if !defined(STBI_NO_FAILURE_STRINGS) && !defined(STBI_FAILURE_USERMSG)
                // not threadsafe
                static char invalid_chunk[] = "XXXX chunk not known";
-               invalid_chunk[0] = (uint8) (c.type >> 24);
-               invalid_chunk[1] = (uint8) (c.type >> 16);
-               invalid_chunk[2] = (uint8) (c.type >>  8);
-               invalid_chunk[3] = (uint8) (c.type >>  0);
+               invalid_chunk[0] = (Uint8) (c.type >> 24);
+               invalid_chunk[1] = (Uint8) (c.type >> 16);
+               invalid_chunk[2] = (Uint8) (c.type >>  8);
+               invalid_chunk[3] = (Uint8) (c.type >>  0);
                #endif
                return e(invalid_chunk, "PNG not supported: unknown chunk type");
             }
@@ -2965,7 +2955,7 @@
 
 static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp)
 {
-   uint8 *out;
+   Uint8 *out;
    unsigned int mr=0,mg=0,mb=0,ma=0, fake_a=0;
    stbi_uc pal[256][4];
    int psize=0,i,j,compress=0,width;
@@ -3120,17 +3110,17 @@
                out[z+0] = get8u(s);
                z += 3;
                a = (easy == 2 ? get8(s) : 255);
-               if (target == 4) out[z++] = (uint8) 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));
+               Uint32 v = (bpp == 16 ? get16le(s) : get32le(s));
                int a;
-               out[z++] = (uint8) shiftsigned(v & mr, rshift, rcount);
-               out[z++] = (uint8) shiftsigned(v & mg, gshift, gcount);
-               out[z++] = (uint8) 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++] = (uint8) a; 
+               if (target == 4) out[z++] = (Uint8) a; 
             }
          }
          skip(s, pad);
@@ -3490,7 +3480,7 @@
    int channelCount, compression;
    int channel, i, count, len;
    int w,h;
-   uint8 *out;
+   Uint8 *out;
 
    // Check identifier
    if (get32(s) != 0x38425053)   // "8BPS"
@@ -3570,7 +3560,7 @@
 
       // Read the RLE data by channel.
       for (channel = 0; channel < 4; channel++) {
-         uint8 *p;
+         Uint8 *p;
          
          p = out+channel;
          if (channel >= channelCount) {
@@ -3593,7 +3583,7 @@
                      len--;
                   }
                } else if (len > 128) {
-                  uint8   val;
+                  Uint8   val;
                   // Next -len+1 bytes in the dest are replicated from next source byte.
                   // (Interpret len as a negative 8-bit int.)
                   len ^= 0x0FF;
@@ -3616,7 +3606,7 @@
       
       // Read the data by channel.
       for (channel = 0; channel < 4; channel++) {
-         uint8 *p;
+         Uint8 *p;
          
          p = out + channel;
          if (channel > channelCount) {
@@ -3767,7 +3757,7 @@
                      if (at_eof(s))   return epuc("bad file","file too short (pure read count)");
 
                      if (count > left)
-                        count = (uint8) left;
+                        count = (Uint8) left;
 
                      if (!pic_readval(s,packet->channel,value))  return 0;
 
@@ -3868,8 +3858,8 @@
 // GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb
 typedef struct stbi_gif_lzw_struct {
    int16 prefix;
-   uint8 first;
-   uint8 suffix;
+   Uint8 first;
+   Uint8 suffix;
 } stbi_gif_lzw;
 
 typedef struct stbi_gif_struct
@@ -3877,10 +3867,10 @@
    int w,h;
    stbi_uc *out;                 // output buffer (always 4 components)
    int flags, bgindex, ratio, transparent, eflags;
-   uint8  pal[256][4];
-   uint8 lpal[256][4];
+   Uint8  pal[256][4];
+   Uint8 lpal[256][4];
    stbi_gif_lzw codes[4096];
-   uint8 *color_table;
+   Uint8 *color_table;
    int parse, step;
    int lflags;
    int start_x, start_y;
@@ -3906,7 +3896,7 @@
    return r;
 }
 
-static void stbi_gif_parse_colortable(stbi *s, uint8 pal[256][4], int num_entries, int transp)
+static void stbi_gif_parse_colortable(stbi *s, Uint8 pal[256][4], int num_entries, int transp)
 {
    int i;
    for (i=0; i < num_entries; ++i) {
@@ -3919,7 +3909,7 @@
 
 static int stbi_gif_header(stbi *s, stbi_gif *g, int *comp, int is_info)
 {
-   uint8 version;
+   Uint8 version;
    if (get8(s) != 'G' || get8(s) != 'I' || get8(s) != 'F' || get8(s) != '8')
       return e("not GIF", "Corrupt GIF");
 
@@ -3957,9 +3947,9 @@
    return 1;
 }
 
-static void stbi_out_gif_code(stbi_gif *g, uint16 code)
+static void stbi_out_gif_code(stbi_gif *g, Uint16 code)
 {
-   uint8 *p, *c;
+   Uint8 *p, *c;
 
    // recurse to decode the prefixes, since the linked-list is backwards,
    // and working backwards through an interleaved image would be nasty
@@ -3991,11 +3981,11 @@
    }
 }
 
-static uint8 *stbi_process_gif_raster(stbi *s, stbi_gif *g)
+static Uint8 *stbi_process_gif_raster(stbi *s, stbi_gif *g)
 {
-   uint8 lzw_cs;
+   Uint8 lzw_cs;
    int32 len, code;
-   uint32 first;
+   Uint32 first;
    int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear;
    stbi_gif_lzw *p;
 
@@ -4008,8 +3998,8 @@
    valid_bits = 0;
    for (code = 0; code < clear; code++) {
       g->codes[code].prefix = -1;
-      g->codes[code].first = (uint8) code;
-      g->codes[code].suffix = (uint8) code;
+      g->codes[code].first = (Uint8) code;
+      g->codes[code].suffix = (Uint8) code;
    }
 
    // support no starting clear code
@@ -4055,7 +4045,7 @@
             } else if (code == avail)
                return epuc("illegal code in raster", "Corrupt GIF");
 
-            stbi_out_gif_code(g, (uint16) code);
+            stbi_out_gif_code(g, (Uint16) code);
 
             if ((avail & codemask) == 0 && avail <= 0x0FFF) {
                codesize++;
@@ -4073,10 +4063,10 @@
 static void stbi_fill_gif_background(stbi_gif *g)
 {
    int i;
-   uint8 *c = g->pal[g->bgindex];
+   Uint8 *c = g->pal[g->bgindex];
    // @OPTIMIZE: write a dword at a time
    for (i = 0; i < g->w * g->h * 4; i += 4) {
-      uint8 *p  = &g->out[i];
+      Uint8 *p  = &g->out[i];
       p[0] = c[2];
       p[1] = c[1];
       p[2] = c[0];
@@ -4085,21 +4075,21 @@
 }
 
 // this function is designed to support animated gifs, although stb_image doesn't support it
-static uint8 *stbi_gif_load_next(stbi *s, stbi_gif *g, int *comp, int req_comp)
+static Uint8 *stbi_gif_load_next(stbi *s, stbi_gif *g, int *comp, int req_comp)
 {
    int i;
-   uint8 *old_out = 0;
+   Uint8 *old_out = 0;
 
    if (g->out == 0) {
       if (!stbi_gif_header(s, g, comp,0))     return 0; // failure_reason set by stbi_gif_header
-      g->out = (uint8 *) malloc(4 * g->w * g->h);
+      g->out = (Uint8 *) malloc(4 * g->w * g->h);
       if (g->out == 0)                      return epuc("outofmem", "Out of memory");
       stbi_fill_gif_background(g);
    } else {
       // animated-gif-only path
       if (((g->eflags & 0x1C) >> 2) == 3) {
          old_out = g->out;
-         g->out = (uint8 *) malloc(4 * g->w * g->h);
+         g->out = (Uint8 *) malloc(4 * g->w * g->h);
          if (g->out == 0)                   return epuc("outofmem", "Out of memory");
          memcpy(g->out, old_out, g->w*g->h*4);
       }
@@ -4110,7 +4100,7 @@
          case 0x2C: // Image Descriptor
          {
             int32 x, y, w, h;
-            uint8 *o;
+            Uint8 *o;
 
             x = get16le(s);
             y = get16le(s);
@@ -4139,13 +4129,13 @@
 
             if (g->lflags & 0x80) {
                stbi_gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1);
-               g->color_table = (uint8 *) g->lpal;       
+               g->color_table = (Uint8 *) g->lpal;       
             } else if (g->flags & 0x80) {
                for (i=0; i < 256; ++i)  // @OPTIMIZE: reset only the previous transparent
                   g->pal[i][3] = 255; 
                if (g->transparent >= 0 && (g->eflags & 0x01))
                   g->pal[g->transparent][3] = 0;
-               g->color_table = (uint8 *) g->pal;
+               g->color_table = (Uint8 *) g->pal;
             } else
                return epuc("missing color table", "Corrupt GIF");
    
@@ -4177,7 +4167,7 @@
          }
 
          case 0x3B: // gif stream termination code
-            return (uint8 *) 1;
+            return (Uint8 *) 1;
 
          default:
             return epuc("unknown code", "Corrupt GIF");
@@ -4187,7 +4177,7 @@
 
 static stbi_uc *stbi_gif_load(stbi *s, int *x, int *y, int *comp, int req_comp)
 {
-   uint8 *u = 0;
+   Uint8 *u = 0;
    stbi_gif g={0};
 
    u = stbi_gif_load_next(s, &g, comp, req_comp);
@@ -4347,11 +4337,11 @@
          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)
-            uint8 rgbe[4];
-            rgbe[0] = (uint8) c1;
-            rgbe[1] = (uint8) c2;
-            rgbe[2] = (uint8) len;
-            rgbe[3] = (uint8) get8u(s);
+            Uint8 rgbe[4];
+            rgbe[0] = (Uint8) c1;
+            rgbe[1] = (Uint8) c2;
+            rgbe[2] = (Uint8) len;
+            rgbe[3] = (Uint8) get8u(s);
             hdr_convert(hdr_data, rgbe, req_comp);
             i = 1;
             j = 0;
@@ -4626,7 +4616,7 @@
       1.28 (2010-08-01)
              fix bug in GIF palette transparency (SpartanJ)
       1.27 (2010-08-01)
-             cast-to-uint8 to fix warnings
+             cast-to-Uint8 to fix warnings
       1.26 (2010-07-24)
              fix bug in file buffering for PNG reported by SpartanJ
       1.25 (2010-07-17)
@@ -4643,7 +4633,7 @@
              GIF support from Jean-Marc Lienher
              iPhone PNG-extensions from James Brown
              warning-fixes from Nicolas Schulz and Janez Zemva (i.e. Janez (U+017D)emva)
-      1.21   fix use of 'uint8' in header (reported by jon blow)
+      1.21   fix use of 'Uint8' in header (reported by jon blow)
       1.20   added support for Softimage PIC, by Tom Seddon
       1.19   bug in interlaced PNG corruption check (found by ryg)
       1.18 2008-08-02