rmodels.c, LoadImageFromCgltfImage() : fix base64 padding support

This should fix the issue related to `.gltf` embeded image in base64 format, by ignoring `=` padding and calculating the data size in bytes correctly.
This commit is contained in:
SuperUserNameMan 2024-06-27 12:48:40 +02:00 committed by GitHub
parent 37205bba84
commit 9f1a92441a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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--; // remove optional paddings
int numberOfEncodedBits = base64Size * 6 - ( base64Size * 6 ) % 8 ; // ignore extra bits
int outSize = numberOfEncodedBits / 8 ; // actual encoded bytes
void *data = NULL;
cgltf_options options = { 0 };