mirror of
https://gitea.windcorp.ru/Wind-Corporation/Progressia.git
synced 2025-07-12 15:56:14 +03:00
TMP / assets will be embedded for now
This commit is contained in:
@ -8,6 +8,8 @@
|
||||
|
||||
#include "stb/stb_image.h"
|
||||
|
||||
#include <embedded_resources.h>
|
||||
|
||||
#include "../logging.h"
|
||||
using namespace progressia::main::logging;
|
||||
|
||||
@ -20,23 +22,19 @@ const Image::Byte *Image::getData() const { return data.data(); }
|
||||
|
||||
Image::Byte *Image::getData() { return data.data(); }
|
||||
|
||||
Image loadImage(const std::filesystem::path &path) {
|
||||
Image loadImage(const std::string &path) {
|
||||
|
||||
std::ifstream file(path, std::ios::ate | std::ios::binary);
|
||||
auto resource = __embedded_resources::getEmbeddedResource(path.c_str());
|
||||
|
||||
if (!file.is_open()) {
|
||||
fatal() << "Could not access a PNG image in file " << path;
|
||||
if (resource.data == nullptr) {
|
||||
// REPORT_ERROR
|
||||
progressia::main::logging::fatal()
|
||||
<< "Could not find resource \"" << path << "\"";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::size_t fileSize = static_cast<std::size_t>(file.tellg());
|
||||
std::vector<Image::Byte> png(fileSize);
|
||||
|
||||
file.seekg(0);
|
||||
file.read(reinterpret_cast<char *>(png.data()), fileSize);
|
||||
|
||||
file.close();
|
||||
std::vector<Image::Byte> png(resource.data,
|
||||
resource.data + resource.length);
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
@ -19,7 +19,7 @@ class Image {
|
||||
Byte *getData();
|
||||
};
|
||||
|
||||
Image loadImage(const std::filesystem::path &);
|
||||
Image loadImage(const std::string &);
|
||||
|
||||
} // namespace main
|
||||
} // namespace progressia
|
||||
|
Reference in New Issue
Block a user