diff mbox series

Patch for png_save(), QEMU v8.0

Message ID E1ptqMT-00HAI8-NC.val15032008-mail-ru@smtp44.i.mail.ru (mailing list archive)
State New, archived
Headers show
Series Patch for png_save(), QEMU v8.0 | expand

Commit Message

Валентин May 2, 2023, 1:48 p.m. UTC
Hello!  Currently, png_save() in "console.c" uses "PIXMAN_a8r8g8b8" format when saving png.  ( https://gitlab.com/qemu-project/qemu/-/blob/7c18f2d663521f1b31b821a13358ce38075eaf7d/ui/console.c#L314 )  It should probably use "PIXMAN_a8b8g8r8" (red<>blue exchanged). Without it I'm getting PNGs with blue and red channels swapped (QEMU 8.0, qemu-system-x86_64, Arm64 host, libpng 1.6.39).  Steps to reproduce: in QEMU 8.0 console execute "screendump /path/to/screenshot.png -f png".  The patch is in attachment. With best regards, Valentine.

Comments

Peter Maydell May 2, 2023, 1:59 p.m. UTC | #1
On Tue, 2 May 2023 at 14:48, Валентин via <qemu-devel@nongnu.org> wrote:
>
> Hello!
>
> Currently, png_save() in "console.c" uses "PIXMAN_a8r8g8b8" format when saving png.
>
> ( https://gitlab.com/qemu-project/qemu/-/blob/7c18f2d663521f1b31b821a13358ce38075eaf7d/ui/console.c#L314 )
>
> It should probably use "PIXMAN_a8b8g8r8" (red<>blue exchanged).
> Without it I'm getting PNGs with blue and red channels swapped (QEMU 8.0, qemu-system-x86_64, Arm64 host, libpng 1.6.39).

Ah, I was just working on this this afternoon (it was reported
last week as https://gitlab.com/qemu-project/qemu/-/issues/1622 )
and just sent a patch a minute before I read this email :-)

I think your patch only fixes this problem for little-endian
hosts and leaves big-endian hosts still with the wrong
pixel-data order.

You can see my version of the patch here:
https://patchew.org/QEMU/20230502135548.2451309-1-peter.maydell@linaro.org/

thanks
-- PMM
diff mbox series

Patch

diff -ru --no-dereference /tmp/qemu-8.0.0/ui/console.c ./ui/console.c
--- /tmp/qemu-8.0.0/ui/console.c	2023-04-19 16:31:47.000000000 +0000
+++ ./ui/console.c	2023-05-02 12:59:02.600469950 +0000
@@ -311,7 +311,7 @@ 
     png_struct *png_ptr;
     png_info *info_ptr;
     g_autoptr(pixman_image_t) linebuf =
-                            qemu_pixman_linebuf_create(PIXMAN_a8r8g8b8, width);
+                            qemu_pixman_linebuf_create(PIXMAN_a8b8g8r8, width);
     uint8_t *buf = (uint8_t *)pixman_image_get_data(linebuf);
     FILE *f = fdopen(fd, "wb");
     int y;