From 0dcb2830c69aba7f1a2e3cf52550a7eb4b643978 Mon Sep 17 00:00:00 2001 From: ZXCLI Date: Wed, 19 Aug 2026 15:46:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B0=83=E8=89=B2=E6=9D=BF?= =?UTF-8?q?=20BGR/RGB=20=E9=A1=BA=E5=BA=8F=EF=BC=9Arender=20=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E6=A0=87=E5=87=86=20RGB24=EF=BC=88=E5=AE=98=E6=96=B9?= =?UTF-8?q?=20palette=20=E4=B8=BA=20BGR=20=E5=AD=98=E5=82=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - mag160c_render_frame 之前把 palette[gv][0]=B 直接写入 out_rgb[0], 导致 R/B 互换,高温区域显示为蓝色 - 改为 out_rgb = {palette[2], palette[1], palette[0]} 标准 RGB24 - linux_demo 的 BMP 输出相应改为写回 BGR(BMP 原生顺序) - 实测:最热像素 (255,255,150) 亮黄白,低温区域蓝黑,色温方向正确 --- build-artifacts/mag160c_demo3.exe | 2 +- csdk/src/mag160c_render.c | 6 +++--- csdk/tools/mag160c_linux_demo.c | 9 +++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/build-artifacts/mag160c_demo3.exe b/build-artifacts/mag160c_demo3.exe index cd79829..2cc60e2 100644 --- a/build-artifacts/mag160c_demo3.exe +++ b/build-artifacts/mag160c_demo3.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0a85090dc4c671f8686097fca408b7df98f5105aca6c399a21c91b947cf61699 +oid sha256:7871c752e49f5f5af71920ac63d072997008a5781f6aea0e35eb1eb1d4744441 size 140785 diff --git a/csdk/src/mag160c_render.c b/csdk/src/mag160c_render.c index 9ba9e89..dfb34a7 100644 --- a/csdk/src/mag160c_render.c +++ b/csdk/src/mag160c_render.c @@ -626,12 +626,12 @@ mag160c_error_t mag160c_render_frame(mag160c_render_t *r, const uint8_t *frame, if (r->post_gray_cb) r->post_gray_cb(r->post_gray_user, r->gray160); upscale2x(r); - /* palette colorize 320x240 */ + /* palette colorize 320x240 (palette is B,G,R -> swap to RGB24 out) */ for (int i = 0; i < r->npix * 4; ++i) { unsigned char gv = r->gray320[i]; - out_rgb[i * 3 + 0] = mag160c_official_palette256[gv][0]; + out_rgb[i * 3 + 0] = mag160c_official_palette256[gv][2]; out_rgb[i * 3 + 1] = mag160c_official_palette256[gv][1]; - out_rgb[i * 3 + 2] = mag160c_official_palette256[gv][2]; + out_rgb[i * 3 + 2] = mag160c_official_palette256[gv][0]; } return MAG160C_OK; } diff --git a/csdk/tools/mag160c_linux_demo.c b/csdk/tools/mag160c_linux_demo.c index 30e5183..def7ff3 100644 --- a/csdk/tools/mag160c_linux_demo.c +++ b/csdk/tools/mag160c_linux_demo.c @@ -102,8 +102,13 @@ static void save_bmp(const char *path, const uint8_t *rgb, int w, int h) { FILE *f = fopen(path, "wb"); if (!f) return; fwrite(bmp, 1, 54, f); - for (int y = h - 1; y >= 0; --y) - fwrite(rgb + (size_t)y * w * 3, 1, (size_t)w * 3, f); + for (int y = h - 1; y >= 0; --y) { + const uint8_t *row = rgb + (size_t)y * w * 3; + for (int x = 0; x < w; ++x) { + uint8_t bgr[3] = { row[x * 3 + 2], row[x * 3 + 1], row[x * 3] }; + fwrite(bgr, 1, 3, f); + } + } fclose(f); }