From 7f25157cbdd4a1f35601bec7f053eea68e8e7674 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sat, 19 Jul 2025 23:36:20 +0000 Subject: [PATCH] plug-ins: Fix bug with RGB FITS export Resolves #13842 fits_write_img () was incorrectly used, since we were writing one channel of RRR...GGG...BBB... data at a time. This patch switches to fits_write_pix (), and increments the first pixel's 3rd index after writing each channel so that the next channel is written from the correct starting point. (cherry picked from commit 1376d254538b99b30b3d7a35843da6a2078c2cfa) --- plug-ins/file-fits/fits.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plug-ins/file-fits/fits.c b/plug-ins/file-fits/fits.c index b4a8dbb433..898df77d64 100644 --- a/plug-ins/file-fits/fits.c +++ b/plug-ins/file-fits/fits.c @@ -889,12 +889,14 @@ export_fits (GFile *file, } else { + glong fpixel[3] = {1, 1, 1}; gdouble *rgb_data; gdouble *rgb_output; const Babl *rgb_format; const Babl *output_format = babl_format ("Y' double"); const Babl *converted_format; + rgb_format = (channelnum == 3) ? babl_format ("R'G'B' double") : babl_format ("R'G'B'A double"); @@ -943,12 +945,13 @@ export_fits (GFile *file, babl_process (babl_fish (output_format, converted_format), rgb_output, converted_output, nelements); - if (fits_write_img (fptr, export_type, 1, nelements, + if (fits_write_pix (fptr, export_type, fpixel, nelements, converted_output, &status)) { show_fits_errors (status); return FALSE; } + fpixel[2]++; g_free (converted_output); }