MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / stbi__do_png

Function stbi__do_png

lite/example/cpp_example/mge/cv/stb_image.h:5788–5830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5786}
5787
5788static void* stbi__do_png(
5789 stbi__png* p, int* x, int* y, int* n, int req_comp, stbi__result_info* ri) {
5790 void* result = NULL;
5791 if (req_comp < 0 || req_comp > 4)
5792 return stbi__errpuc("bad req_comp", "Internal error");
5793 if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) {
5794 if (p->depth <= 8)
5795 ri->bits_per_channel = 8;
5796 else if (p->depth == 16)
5797 ri->bits_per_channel = 16;
5798 else
5799 return stbi__errpuc(
5800 "bad bits_per_channel",
5801 "PNG not supported: unsupported color depth");
5802 result = p->out;
5803 p->out = NULL;
5804 if (req_comp && req_comp != p->s->img_out_n) {
5805 if (ri->bits_per_channel == 8)
5806 result = stbi__convert_format(
5807 (unsigned char*)result, p->s->img_out_n, req_comp, p->s->img_x,
5808 p->s->img_y);
5809 else
5810 result = stbi__convert_format16(
5811 (stbi__uint16*)result, p->s->img_out_n, req_comp, p->s->img_x,
5812 p->s->img_y);
5813 p->s->img_out_n = req_comp;
5814 if (result == NULL)
5815 return result;
5816 }
5817 *x = p->s->img_x;
5818 *y = p->s->img_y;
5819 if (n)
5820 *n = p->s->img_n;
5821 }
5822 STBI_FREE(p->out);
5823 p->out = NULL;
5824 STBI_FREE(p->expanded);
5825 p->expanded = NULL;
5826 STBI_FREE(p->idata);
5827 p->idata = NULL;
5828
5829 return result;
5830}
5831
5832static void* stbi__png_load(
5833 stbi__context* s, int* x, int* y, int* comp, int req_comp,

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