From 4050207431b1fddf0ebcaf8ea60393cec2c62c33 Mon Sep 17 00:00:00 2001 From: Mithra Kancheti Date: Sat, 23 Mar 2024 04:39:25 -0400 Subject: [PATCH 1/2] Fix support for RGBA PNG images --- example/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/main.cpp b/example/main.cpp index 1c555a5..cf5ae56 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -97,9 +97,9 @@ void overwriteIcon(std::string tid, std::string imagePath) { brls::Logger::info("Image is loaded"); unsigned char* data = NULL; - data = (unsigned char*)malloc(256 * 256 * 3 * sizeof(unsigned char)); + data = (unsigned char*)malloc(256 * 256 * channels * sizeof(unsigned char)); - if (stbir_resize_uint8(img, width, height, 0, data, 256, 256, 256 * 3, 3)) + if (stbir_resize_uint8(img, width, height, 0, data, 256, 256, 256 * channels, channels)) { brls::Logger::info("resize good"); } From 1760d5517b23981a4c947c98d6ea450b0ac319c0 Mon Sep 17 00:00:00 2001 From: Mithra Kancheti Date: Sat, 23 Mar 2024 04:39:56 -0400 Subject: [PATCH 2/2] Fix memory leak in overwriteIcon --- example/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example/main.cpp b/example/main.cpp index cf5ae56..fab6219 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -124,6 +124,8 @@ void overwriteIcon(std::string tid, std::string imagePath) { brls::Application::notify("Icon could not be saved"); }; + stbi_image_free(img); + free(data); } }