Skip to content

Commit c152d4d

Browse files
committed
use the mime type as data type when load the image
1 parent b81a7fa commit c152d4d

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

source/libgltf/gltf_loader.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,6 @@ namespace libgltf
251251
if (glb_chunk_bin.type != ms_GLBChunkTypeBIN) return false;
252252
data.resize(glb_chunk_bin.length);
253253
::memcpy(data.data(), default_file_data.data() + offset, glb_chunk_bin.length);
254-
size_t slash_index = data_type.find_last_of('/');
255-
if (data_type.size() > (slash_index + 1))
256-
{
257-
data_type = data_type.substr(slash_index + 1);
258-
}
259254
return true;
260255
}
261256
else
@@ -265,21 +260,18 @@ namespace libgltf
265260
size_t data_index = 0;
266261
if (UriParse(uri, data_type, data_encode, data_index))
267262
{
268-
size_t slash_index = data_type.find_last_of('/');
269-
if (data_type.size() > (slash_index + 1))
270-
{
271-
data_type = data_type.substr(slash_index + 1);
272-
}
273263
return (StringEqual(data_encode, GLTFTEXT("base64"), false) && base64::Decode(uri.substr(data_index), data));
274264
}
275265
}
266+
276267
/// try to load from file
277268
if (!m_pFileLoader->Load(uri)) return false;
269+
278270
data = (*m_pFileLoader)[uri];
279271
size_t dot_index = uri.find_last_of('.');
280272
if (uri.size() > (dot_index + 1))
281273
{
282-
data_type = uri.substr(dot_index + 1);
274+
data_type = "file/" + uri.substr(dot_index + 1);
283275
}
284276
return true;
285277
}

source/runtest/runtest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ int main(int _iArgc, char* _pcArgv[])
229229
std::vector<uint8_t> image0_data;
230230
libgltf::string_t image0_data_type;
231231
gltf_loader->GetOrLoadImageData(0, image0_data, image0_data_type);
232-
233232

234233
#if defined(LIBGLTF_BUILD_COVERAGE)
235234
const std::string obj_file_path =

0 commit comments

Comments
 (0)