Skip to content

Commit

Permalink
rmodels.c, LoadImageFromCgltfImage() : fix base64 padding support
Browse files Browse the repository at this point in the history
This should fix the issue related to `.gltf` embeded image in base64 format, by ignoring `=` padding and calculating the data size in bytes correctly.
  • Loading branch information
SuperUserNameMan authored Jun 27, 2024
1 parent 37205bb commit 9f1a924
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/rmodels.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit 9f1a924

Please sign in to comment.