| 710 | } |
| 711 | |
| 712 | bool clip_image_load_from_bytes(const unsigned char * bytes, size_t bytes_length, struct clip_image_u8 * img) { |
| 713 | int nx, ny, nc; |
| 714 | auto data = stbi_load_from_memory(bytes, bytes_length, &nx, &ny, &nc, 3); |
| 715 | if (!data) { |
| 716 | fprintf(stderr, "%s: failed to decode image bytes\n", __func__); |
| 717 | return false; |
| 718 | } |
| 719 | build_clip_img_from_data(data, nx, ny, img); |
| 720 | stbi_image_free(data); |
| 721 | return true; |
| 722 | } |
| 723 | |
| 724 | // normalize: x = (x - mean) / std |
| 725 | // TODO: implement bicubic interpolation instead of linear. |
no test coverage detected