| 2096 | } |
| 2097 | |
| 2098 | unsigned char* lf_load_texture_data_resized_factor(const char* filepath, int32_t wfactor, int32_t hfactor, int32_t* width, int32_t* height, int32_t* channels, bool flip) { |
| 2099 | unsigned char* image = stbi_load(filepath, width, height, channels, STBI_rgb_alpha); |
| 2100 | if (!image) { |
| 2101 | return NULL; |
| 2102 | } |
| 2103 | |
| 2104 | float w = (wfactor * (*width)); |
| 2105 | float h = (hfactor * (*height)); |
| 2106 | |
| 2107 | size_t new_size = w * h * (*channels); |
| 2108 | unsigned char* resized_data = (unsigned char*)malloc(new_size); |
| 2109 | if (resized_data == NULL) { |
| 2110 | return NULL; |
| 2111 | } |
| 2112 | |
| 2113 | stbir_resize_uint8_linear(image, *width, *height, *channels, resized_data, w, h, 0,(stbir_pixel_layout)*channels); |
| 2114 | free(image); |
| 2115 | return resized_data; |
| 2116 | |
| 2117 | } |
| 2118 | |
| 2119 | unsigned char* lf_load_texture_data_from_memory(const void* data, size_t size, int32_t* width, int32_t* height, int32_t* channels, bool flip) { |
| 2120 | stbi_set_flip_vertically_on_load(!flip); |
no outgoing calls
no test coverage detected