try to decode the image header as soon as some data is available

This commit is contained in:
2019-09-26 18:34:33 +02:00
parent 8b179260fb
commit 13b2f6eb07
4 changed files with 16 additions and 5 deletions

View File

@@ -135,9 +135,18 @@ bool NodeImage::set_image(const std::string& path)
void NodeImage::load_url(const std::string& url)
{
m_remote_header_decoded = false;
m_remote_asset = std::make_shared<Asset>();
m_remote_asset->open_url_async(url,
[this] (float progress) -> bool {
int w, h, c;
if (!m_remote_header_decoded &&
stbi_info_from_memory(m_remote_asset->tmp_data.data(), m_remote_asset->tmp_data.size(), &w, &h, &c))
{
if (m_autosize)
SetAspectRatio((float)w / (float)h);
m_remote_header_decoded = true;
}
return true;
},
[this] (bool success) {