+static unsigned char *decode_image(downloadinfo *di, const char *content_type)
+{
+ unsigned char *pixels = NULL;
+ fs_offset_t filesize = 0;
+ unsigned char *data = FS_LoadFile(di->filename, tempmempool, true, &filesize);
+ if(data)
+ {
+ int mip = 0;
+ if(!strcmp(content_type, "image/jpeg"))
+ pixels = JPEG_LoadImage_BGRA(data, filesize, &mip);
+ else if(!strcmp(content_type, "image/png"))
+ pixels = PNG_LoadImage_BGRA(data, filesize, &mip);
+ else if(filesize >= 7 && !strncmp((char *) data, "\xFF\xD8", 7))
+ pixels = JPEG_LoadImage_BGRA(data, filesize, &mip);
+ else if(filesize >= 7 && !strncmp((char *) data, "\x89PNG\x0D\x0A\x1A\x0A", 7))
+ pixels = PNG_LoadImage_BGRA(data, filesize, &mip);
+ else
+ Con_Printf("Did not detect content type: %s\n", content_type);
+ Mem_Free(data);
+ }
+ // do we call Image_MakeLinearColorsFromsRGB or not?
+ return pixels;
+}
+