MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__do_png

Function stbi__do_png

Source/Utils/stb_image.h:5260–5290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5258}
5259
5260static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri)
5261{
5262 void *result=NULL;
5263 if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error");
5264 if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) {
5265 if (p->depth <= 8)
5266 ri->bits_per_channel = 8;
5267 else if (p->depth == 16)
5268 ri->bits_per_channel = 16;
5269 else
5270 return stbi__errpuc("bad bits_per_channel", "PNG not supported: unsupported color depth");
5271 result = p->out;
5272 p->out = NULL;
5273 if (req_comp && req_comp != p->s->img_out_n) {
5274 if (ri->bits_per_channel == 8)
5275 result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y);
5276 else
5277 result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y);
5278 p->s->img_out_n = req_comp;
5279 if (result == NULL) return result;
5280 }
5281 *x = p->s->img_x;
5282 *y = p->s->img_y;
5283 if (n) *n = p->s->img_n;
5284 }
5285 STBI_FREE(p->out); p->out = NULL;
5286 STBI_FREE(p->expanded); p->expanded = NULL;
5287 STBI_FREE(p->idata); p->idata = NULL;
5288
5289 return result;
5290}
5291
5292static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
5293{

Callers 1

stbi__png_loadFunction · 0.85

Calls 3

stbi__parse_png_fileFunction · 0.85
stbi__convert_formatFunction · 0.85
stbi__convert_format16Function · 0.85

Tested by

no test coverage detected