diff --git a/src/rmodels.c b/src/rmodels.c index a323292ca7d8..a6209f39f817 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -4815,7 +4815,9 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat else { int base64Size = (int)strlen(cgltfImage->uri + i + 1); - int outSize = 3*(base64Size/4); // TODO: Consider padding (-numberOfPaddingCharacters) + while (cgltfImage->uri[i + base64Size] == '=') base64Size--; // Ignore optional paddings + int numberOfEncodedBits = base64Size*6 - (base64Size*6) % 8 ; // Encoded bits minus extra bits, so it becomes a multiple of 8 bits + int outSize = numberOfEncodedBits/8 ; // Actual encoded bytes void *data = NULL; cgltf_options options = { 0 };