Utility: Fix STBLoader

This commit is contained in:
Jérôme Leclercq 2022-09-07 15:40:14 +02:00 committed by GitHub
parent fbdc1faf8c
commit 5cb50928f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -47,10 +47,14 @@ namespace Nz
Result<std::shared_ptr<Image>, ResourceLoadingError> LoadSTB(Stream& stream, const ImageParams& parameters)
{
UInt64 streamPos = stream.GetCursorPos();
int width, height, bpp;
if (!stbi_info_from_callbacks(&s_stbiCallbacks, &stream, &width, &height, &bpp))
return Err(ResourceLoadingError::Unrecognized);
stream.SetCursorPos(streamPos);
// Load everything as RGBA8 and then convert using the Image::Convert method
// This is because of a STB bug when loading some JPG images with default settings