From f0ee7bee1043204c5800a21750a50c0da507d9c4 Mon Sep 17 00:00:00 2001 From: David Korth Date: Mon, 16 Jun 2025 00:51:54 -0400 Subject: [PATCH] [librptexture] Qoi: qoi.h has the R and B channels swapped compared to what rp_image expects. This was broken since support for Qoi was added in v2.5. Not sure why I didn't notice it until now... Affects: v2.4 - v2.5 --- NEWS.md | 2 ++ src/librptexture/fileformat/Qoi.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index d7e9ebcaf..7119504f0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -33,6 +33,8 @@ empty data as a PNG image. (Needs more debugging for a proper fix...) * See #451: libpng errors crash due to libpng setjmp/longjmp (Windows 10, release builds only) * Reported by @Masamune3210. + * Qoi: R/B channels were incorrectly swapped when this was first added in v2.5. + * Affects: v2.5 - v2.5.1 * Other changes: * rpcli: Added more colorization for warning messages. diff --git a/src/librptexture/fileformat/Qoi.cpp b/src/librptexture/fileformat/Qoi.cpp index b1c899362..24276b6ad 100644 --- a/src/librptexture/fileformat/Qoi.cpp +++ b/src/librptexture/fileformat/Qoi.cpp @@ -162,7 +162,14 @@ rp_image_const_ptr QoiPrivate::loadImage(void) px_src += src_stride; } free(pixels); - + + // NOTE: qoi.h has the R and B channels swapped compared to what rp_image expects. + int ret = tmp_img->swizzle("bgra"); + if (ret != 0) { + // Swizzle failed. + return {}; + } + img.reset(tmp_img); return img; }