Compare commits

...

2 Commits

Author SHA1 Message Date
Green Sky
aa8bacc18f fix more warnings
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android-23]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android-23]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android-23]) (push) Has been cancelled
ContinuousDelivery / windows (windows-2022, ) (push) Has been cancelled
ContinuousDelivery / windows (windows-2022, asan) (push) Has been cancelled
ContinuousDelivery / dumpsyms (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
ContinuousIntegration / on ubuntu-24.04-arm (push) Has been cancelled
ContinuousIntegration / asan on ubuntu-24.04-arm (push) Has been cancelled
ContinuousIntegration / on ubuntu-latest (push) Has been cancelled
ContinuousIntegration / asan on ubuntu-latest (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android-23]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android-23]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android-23]) (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
2025-12-19 13:28:26 +01:00
Green Sky
47278807f6 fix image loader warning by better handling errors 2025-12-19 13:23:38 +01:00
3 changed files with 14 additions and 9 deletions

View File

@@ -65,7 +65,7 @@ std::optional<TextureEntry> BitsetImageLoader::haveToTexture(TextureUploaderI& t
BitsetImageLoader::BitsetImageLoader(void) {
}
TextureLoaderResult BitsetImageLoader::load(TextureUploaderI& tu, ObjectHandle o, uint32_t w, uint32_t h) {
TextureLoaderResult BitsetImageLoader::load(TextureUploaderI& tu, ObjectHandle o, uint32_t /*w*/, uint32_t /*h*/) {
if (!static_cast<bool>(o)) {
std::cerr << "BIL error: trying to load invalid object\n";
return {};

View File

@@ -6,9 +6,14 @@
#include "./image_scaler.hpp"
ImageLoaderI::ImageResult ImageLoaderI::ImageResult::crop(int32_t c_x, int32_t c_y, int32_t c_w, int32_t c_h) const {
// TODO: proper error handling
assert(c_x+c_w <= width);
assert(c_y+c_h <= height);
if (
c_x < 0 || c_y < 0 || c_w < 1 || c_h < 1 ||
int64_t(c_x) + int64_t(c_w) > int64_t(width) || int64_t(c_y) + int64_t(c_h) > int64_t(height)
) {
// unreachable
assert(false && "invalid image crop");
return *this;
}
ImageLoaderI::ImageResult new_image;
new_image.width = c_w;
@@ -19,7 +24,7 @@ ImageLoaderI::ImageResult ImageLoaderI::ImageResult::crop(int32_t c_x, int32_t c
auto& new_frame = new_image.frames.emplace_back();
new_frame.ms = input_frame.ms;
// TODO: improve this, this is super inefficent
// TODO: improve this, this is inefficent
for (int64_t y = c_y; y < c_y + c_h; y++) {
for (int64_t x = c_x; x < c_x + c_w; x++) {
new_frame.data.push_back(input_frame.data.at(y*width*4+x*4+0));

View File

@@ -89,8 +89,8 @@ std::vector<uint8_t> ImageEncoderSTBPNG::encodeToMemoryRGBA(const ImageResult& i
struct Context {
std::vector<uint8_t> new_data;
} context;
auto write_f = +[](void* context, void* data, int size) -> void {
Context* ctx = reinterpret_cast<Context*>(context);
auto write_f = +[](void* context_, void* data, int size) -> void {
Context* ctx = reinterpret_cast<Context*>(context_);
uint8_t* d = reinterpret_cast<uint8_t*>(data);
ctx->new_data.insert(ctx->new_data.cend(), d, d + size);
};
@@ -126,8 +126,8 @@ std::vector<uint8_t> ImageEncoderSTBJpeg::encodeToMemoryRGBA(const ImageResult&
struct Context {
std::vector<uint8_t> new_data;
} context;
auto write_f = +[](void* context, void* data, int size) -> void {
Context* ctx = reinterpret_cast<Context*>(context);
auto write_f = +[](void* context_, void* data, int size) -> void {
Context* ctx = reinterpret_cast<Context*>(context_);
uint8_t* d = reinterpret_cast<uint8_t*>(data);
ctx->new_data.insert(ctx->new_data.cend(), d, d + size);
};