STBI: Handle UTF-8 paths correctly

This commit is contained in:
Silent
2020-09-14 21:27:22 +02:00
parent a35a2838b6
commit 1918a5ddd4
3 changed files with 49 additions and 16 deletions

View File

@ -1,4 +1,5 @@
#include "image.h"
#include "file_system.h"
#include "log.h"
#include "stb_image.h"
Log_SetChannel(Common::Image);
@ -6,8 +7,14 @@ Log_SetChannel(Common::Image);
namespace Common {
bool LoadImageFromFile(Common::RGBA8Image* image, const char* filename)
{
auto fp = FileSystem::OpenManagedCFile(filename, "rb");
if (!fp)
{
return false;
}
int width, height, file_channels;
u8* pixel_data = stbi_load(filename, &width, &height, &file_channels, 4);
u8* pixel_data = stbi_load_from_file(fp.get(), &width, &height, &file_channels, 4);
if (!pixel_data)
{
const char* error_reason = stbi_failure_reason();