Use function GetSizeBase64()
This commit is contained in:
parent
4ad1fa85a4
commit
f9a2d89ed2
1 changed files with 7 additions and 13 deletions
14
src/models.c
14
src/models.c
|
@ -3278,16 +3278,7 @@ static int GetSizeBase64(char *input)
|
||||||
|
|
||||||
static unsigned char *DecodeBase64(char *input, int *size)
|
static unsigned char *DecodeBase64(char *input, int *size)
|
||||||
{
|
{
|
||||||
*size = 0;
|
*size = GetSizeBase64(input);
|
||||||
for (int i = 0; input[4*i] != 0; i++)
|
|
||||||
{
|
|
||||||
if (input[4*i + 3] == '=')
|
|
||||||
{
|
|
||||||
if (input[4*i + 2] == '=') *size += 1;
|
|
||||||
else *size += 2;
|
|
||||||
}
|
|
||||||
else *size += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char *buf = (unsigned char *)RL_MALLOC(*size);
|
unsigned char *buf = (unsigned char *)RL_MALLOC(*size);
|
||||||
for (int i = 0; i < *size/3; i++)
|
for (int i = 0; i < *size/3; i++)
|
||||||
|
@ -3444,8 +3435,10 @@ static Model LoadGLTF(const char *fileName)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
unsigned char *data = DecodeBase64(img->uri + i + 1, &size);
|
unsigned char *data = DecodeBase64(img->uri + i + 1, &size);
|
||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
unsigned char *raw = stbi_load_from_memory(data, size, &w, &h, NULL, 4);
|
unsigned char *raw = stbi_load_from_memory(data, size, &w, &h, NULL, 4);
|
||||||
|
|
||||||
Image image = LoadImagePro(raw, w, h, UNCOMPRESSED_R8G8B8A8);
|
Image image = LoadImagePro(raw, w, h, UNCOMPRESSED_R8G8B8A8);
|
||||||
ImageColorTint(&image, tint);
|
ImageColorTint(&image, tint);
|
||||||
texture = LoadTextureFromImage(image);
|
texture = LoadTextureFromImage(image);
|
||||||
|
@ -3480,6 +3473,7 @@ static Model LoadGLTF(const char *fileName)
|
||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
unsigned char *raw = stbi_load_from_memory(data, img->buffer_view->size, &w, &h, NULL, 4);
|
unsigned char *raw = stbi_load_from_memory(data, img->buffer_view->size, &w, &h, NULL, 4);
|
||||||
|
|
||||||
Image image = LoadImagePro(raw, w, h, UNCOMPRESSED_R8G8B8A8);
|
Image image = LoadImagePro(raw, w, h, UNCOMPRESSED_R8G8B8A8);
|
||||||
ImageColorTint(&image, tint);
|
ImageColorTint(&image, tint);
|
||||||
texture = LoadTextureFromImage(image);
|
texture = LoadTextureFromImage(image);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue