From 94649915ac108fb88b30f5ffda4606c4a1166289 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Mon, 11 Sep 2023 19:58:14 +0100 Subject: [PATCH] Fix SVG colors (bug#56182) * src/image.c (svg_load_image): Reverse the R and B bytes in the Windows colors before using them to generate the SVG. --- src/image.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/image.c b/src/image.c index a4b8d21cee6..84db9bfb3b8 100644 --- a/src/image.c +++ b/src/image.c @@ -12075,6 +12075,18 @@ svg_load_image (struct frame *f, struct image *img, char *contents, img->background_valid = 1; } +#if HAVE_NTGUI + /* Windows stores the image colours in BGR format, and SVG expects + them in RGB. */ + foreground = (foreground & 0x0000FF) << 16 + | (foreground & 0xFF0000) >> 16 + | (foreground & 0x00FF00); + + background = (background & 0x0000FF) << 16 + | (background & 0xFF0000) >> 16 + | (background & 0x00FF00); +#endif + wrapped_contents = xmalloc (buffer_size); if (buffer_size <= snprintf (wrapped_contents, buffer_size, wrapper, -- 2.40.1