qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Patch for png_save(), QEMU v8.0
@ 2023-05-02 13:48 Валентин via
  2023-05-02 13:59 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Валентин via @ 2023-05-02 13:48 UTC (permalink / raw)
  To: qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 552 bytes --]

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.

[-- Attachment #1.2: Type: text/html, Size: 1013 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 800_abgr.patch --]
[-- Type: text/x-diff; name="800_abgr.patch", Size: 576 bytes --]

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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patch for png_save(), QEMU v8.0
  2023-05-02 13:48 Patch for png_save(), QEMU v8.0 Валентин via
@ 2023-05-02 13:59 ` Peter Maydell
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2023-05-02 13:59 UTC (permalink / raw)
  To: Валентин; +Cc: qemu-devel

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patch for png_save(), QEMU v8.0
       [not found] <6hqkbi1b7alen721of3thdv8.1683036666264@email.android.com>
@ 2023-05-02 14:37 ` Валентин
  0 siblings, 0 replies; 3+ messages in thread
From: Валентин @ 2023-05-02 14:37 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1364 bytes --]

Thank you! Indeed, I haven't took into account big-endian hosts. (I tried "PIXMAN_BE_r8g8b8" as in ppm_save(), but didn't fix png header and got broken images).  Your patch should be correct.  Thank you very much! With best regards, Valentine.    
-------- Исходное сообщение --------От: Peter Maydell <peter.maydell@linaro.org> Дата: 02.05.2023  16:59  (GMT+03:00)Тема: Re: Patch for png_save(), QEMU v8.0 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 reportedlast 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-endianhosts and leaves big-endian hosts still with the wrongpixel-data order.You can see my version of the patch here:https://patchew.org/QEMU/20230502135548.2451309-1-peter.maydell@linaro.org/thanks-- PMM

[-- Attachment #2: Type: text/html, Size: 2351 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-02 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-02 13:48 Patch for png_save(), QEMU v8.0 Валентин via
2023-05-02 13:59 ` Peter Maydell
     [not found] <6hqkbi1b7alen721of3thdv8.1683036666264@email.android.com>
2023-05-02 14:37 ` Валентин

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).