Home | History | Annotate | Download | only in stbi

Lines Matching defs:png

1 /* stbi-1.29 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c
10 PNG 8-bit only
28 1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ
38 iPhone PNG-extensions from James Brown
55 Sean Barrett (jpeg, png, bmp) Fabian "ryg" Giesen
65 James "moose2000" Brown (iPhone PNG) Laurent Gomila
87 // - non-HDR formats support 8-bit samples only (jpeg, png)
132 // Paletted PNG, BMP, GIF, and PIC images are automatically depalettized.
136 // iPhone PNG support:
262 // ZLIB client - used by PNG, available for other purposes
328 // is it a png?
516 // is it a png?
969 // and it never has alpha, so very few cases ). png can automatically
2262 // zlib-from-memory implementation for PNG reading
2263 // because PNG allows splitting the zlib stream arbitrarily,
2264 // and it's annoying structurally to have PNG call ZLIB call PNG,
2265 // we require PNG read all the IDATs and combine them into a single
2338 if (!z->z_expandable) return e("output buffer limit","Corrupt PNG");
2370 if (z < 0) return e("bad huffman code","Corrupt PNG"); // error in huffman codes
2381 if (z < 0) return e("bad huffman code","Corrupt PNG");
2384 if (a->zout - a->zout_start < dist) return e("bad dist","Corrupt PNG");
2433 if (n != hlit+hdist) return e("bad codelengths","Corrupt PNG");
2458 if (nlen != (len ^ 0xffff)) return e("zlib corrupt","Corrupt PNG");
2459 if (a->zbuffer + len > a->zbuffer_end) return e("read past buffer","Corrupt PNG");
2474 if ((cmf*256+flg) % 31 != 0) return e("bad zlib header","Corrupt PNG"); // zlib spec
2475 if (flg & 32) return e("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png
2476 if (cm != 8) return e("bad compression","Corrupt PNG"); // DEFLATE required for png
2494 int stbi_png_partial; // a quick hack to only allow decoding some of a PNG... I should implement real streaming support instead
2643 // public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18
2675 if (get8(s) != png_sig[i]) return e("bad png sig","Not a PNG");
2683 } png;
2707 // create the png data from post-deflated data
2708 static int create_png_image_raw(png *a, uint8 *raw, uint32 raw_len, int out_n, uint32 x, uint32 y)
2720 if (raw_len != (img_n * x + 1) * y) return e("not enough pixels","Corrupt PNG");
2722 if (raw_len < (img_n * x + 1) * y) return e("not enough pixels","Corrupt PNG");
2729 if (filter > 4) return e("invalid filter","Corrupt PNG");
2799 static int create_png_image(png *a, uint8 *raw, uint32 raw_len, int out_n, int interlaced)
2840 static int compute_transparency(png *z, uint8 tc[3], int out_n)
2865 static int expand_palette(png *a, uint8 *palette, int len, int pal_img_n)
2914 static void stbi_de_iphone(png *z)
2956 static int parse_png_file(png *z, int scan, int req_comp)
2977 if (!first) return e("multiple IHDR","Corrupt PNG");
2979 if (c.length != 13) return e("bad IHDR len","Corrupt PNG");
2982 depth = get8(s); if (depth != 8) return e("8bit only","PNG not supported: 8-bit only");
2983 color = get8(s); if (color > 6) return e("bad ctype","Corrupt PNG");
2984 if (color == 3) pal_img_n = 3; else if (color & 1) return e("bad ctype","Corrupt PNG");
2985 comp = get8(s); if (comp) return e("bad comp method","Corrupt PNG");
2986 filter= get8(s); if (filter) return e("bad filter method","Corrupt PNG");
2987 interlace = get8(s); if (interlace>1) return e("bad interlace method","Corrupt PNG");
2988 if (!s->img_x || !s->img_y) return e("0-pixel image","Corrupt PNG");
2997 if ((1 << 30) / s->img_x / 4 < s->img_y) return e("too large","Corrupt PNG");
3004 if (first) return e("first not IHDR", "Corrupt PNG");
3005 if (c.length > 256*3) return e("invalid PLTE","Corrupt PNG");
3007 if (pal_len * 3 != c.length) return e("invalid PLTE","Corrupt PNG");
3018 if (first) return e("first not IHDR", "Corrupt PNG");
3019 if (z->idata) return e("tRNS after IDAT","Corrupt PNG");
3022 if (pal_len == 0) return e("tRNS before PLTE","Corrupt PNG");
3023 if (c.length > pal_len) return e("bad tRNS len","Corrupt PNG");
3028 if (!(s->img_n & 1)) return e("tRNS with alpha","Corrupt PNG");
3029 if (c.length != (uint32) s->img_n*2) return e("bad tRNS len","Corrupt PNG");
3038 if (first) return e("first not IHDR", "Corrupt PNG");
3039 if (pal_img_n && !pal_len) return e("no PLTE","Corrupt PNG");
3049 if (!getn(s, z->idata+ioff,c.length)) return e("outofdata","Corrupt PNG");
3056 if (first) return e("first not IHDR", "Corrupt PNG");
3058 if (z->idata == NULL) return e("no IDAT","Corrupt PNG");
3085 if (first) return e("first not IHDR", "Corrupt PNG");
3095 return e(invalid_chunk, "PNG not supported: unknown chunk type");
3105 static unsigned char *do_png(png *p, int *x, int *y, int *n, int req_comp)
3133 png p;
3151 png p;
3159 png p;
3171 png p;
3176 static int stbi_png_info_raw(png *p, int *x, int *y, int *comp)
3199 png p;
3211 png p;
5016 fix bug in file buffering for PNG reported by SpartanJ
5030 iPhone PNG-extensions from James Brown
5034 1.19 bug in interlaced PNG corruption check (found by ryg)
5037 1.17 support interlaced PNG
5077 0.53 fix bug in png 3->4; speedup png decoding
5078 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments