mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2025-12-06 04:04:53 +01:00
Add avatar image loading from global ...
... settings directory. Also adds some additional related debug logging, and a utility function for converting between std::vector<image_pixel_t> used by Local_Storage::load_image(), and std::string used by Settings::add_image().
This commit is contained in:
parent
0eaba52f76
commit
d493e30b98
4 changed files with 58 additions and 1 deletions
|
|
@ -34,6 +34,19 @@ struct File_Data {
|
|||
std::string name;
|
||||
};
|
||||
|
||||
std::string convert_vector_image_pixel_t_to_std_string(std::vector<image_pixel_t> & in) {
|
||||
std::string out;
|
||||
|
||||
for (auto i : in) {
|
||||
out += i.channels.r;
|
||||
out += i.channels.g;
|
||||
out += i.channels.b;
|
||||
out += i.channels.a;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
#ifdef NO_DISK_WRITES
|
||||
std::string Local_Storage::get_program_path()
|
||||
{
|
||||
|
|
@ -807,6 +820,10 @@ std::vector<image_pixel_t> Local_Storage::load_image(std::string const& image_pa
|
|||
std::copy(img, img + width * height, res.begin());
|
||||
|
||||
stbi_image_free(img);
|
||||
} else {
|
||||
width = 0;
|
||||
height = 0;
|
||||
PRINT_DEBUG("%s %s. reason: %s\n", "Failed to load image at", image_path.c_str(), stbi_failure_reason());
|
||||
}
|
||||
if (out_width != nullptr) {
|
||||
if (width > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue