diff options
| author | SuperUserNameMan <[email protected]> | 2024-06-28 09:56:27 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-06-28 09:56:27 +0200 |
| commit | a3ef381b3e55cd2a7cf2a521f136330a295c5a9d (patch) | |
| tree | f3aee0ce96032deb455bb5fcff7c7eebd03f92c1 /src | |
| parent | 84971d81f3383e108c2369d9a0690031e6105087 (diff) | |
| download | raylib-a3ef381b3e55cd2a7cf2a521f136330a295c5a9d.tar.gz raylib-a3ef381b3e55cd2a7cf2a521f136330a295c5a9d.zip | |
rmodels.c, `LoadImageFromCgltfImage()` : fix base64 padding support (#4112)
* 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.
* follow guidelin convention
* try to follow guideline convention as much as possible
* clarify comments
i hope it's clear ennough
Diffstat (limited to 'src')
| -rw-r--r-- | src/rmodels.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/rmodels.c b/src/rmodels.c index f99ba514..cc6ac823 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 }; |
