Merge pull request #677 from chentong-net/iphone-png-conversion-in-mem
Some checks are pending
CI / build (ubuntu-latest) (push) Waiting to run

Fix iPhone PNG color issues when loading images from memory in NanoVG
This commit is contained in:
Mikko Mononen 2026-02-19 15:29:32 +02:00 • committed by GitHub
commit ce3bf745eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -814,6 +814,8 @@ int nvgCreateImage(NVGcontext* ctx, const char* filename, int imageFlags)
int nvgCreateImageMem(NVGcontext* ctx, int imageFlags, unsigned char* data, int ndata) int nvgCreateImageMem(NVGcontext* ctx, int imageFlags, unsigned char* data, int ndata)
{ {
int w, h, n, image; int w, h, n, image;
stbi_set_unpremultiply_on_load(1);
stbi_convert_iphone_png_to_rgb(1);
unsigned char* img = stbi_load_from_memory(data, ndata, &w, &h, &n, 4); unsigned char* img = stbi_load_from_memory(data, ndata, &w, &h, &n, 4);
if (img == NULL) { if (img == NULL) {
// printf("Failed to load %s - %s\n", filename, stbi_failure_reason()); // printf("Failed to load %s - %s\n", filename, stbi_failure_reason());