bug#80281: 31.0.50; FR: Canvas object as display property

Alan Third <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
On Sat, Aug 08, 2026 at 05:16:58PM +0300, Eli Zaretskii wrote:
> > From: Divya Ranjan Pattanaik <[email protected]>
> > Cc: [email protected], Daniel Mendler <[email protected]>,
> >  [email protected], [email protected], [email protected],
> >  [email protected]
> > Date: Sat, 01 Aug 2026 14:17:15 +0000
> > 
> > +@deftypefn Function uint32_t *canvas_data (emacs_env *@var{env}, emacs_value @var{canvas})
> > +The function gives access to the pixel buffer of @var{canvas}.  The
> > +pixel buffer is in row-major order with a size @var{width} * @var{height}.
> > +The pixel format is ARGB32 on all platforms.  Return @code{NULL} in case
>    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Is this factually correct?  What about Windows, where the native
> format is BGR AFAIU?  Or is the above correct only because Windows is
> not currently supported?

Hi Eli,

as I understand it this is correct, the buffer is ARGB32. It gets
converted to the native format in canvas_prepare_for_display:

+#else
+  /* Platform independent canvas reloading.  Less efficient, since it recreates images and pixmaps. */
+  FRAME_TERMINAL (f)->free_pixmap (f, img->pixmap);
+  img->pixmap = NO_PIXMAP;
+  Emacs_Pix_Container ximg;
+  if (image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
+    {
+      for (int y = 0; y < height; ++y)
+        for (int x = 0; x < width; ++x)
+          {
+            uint32_t c = src[y * width + x],
                      ^ ARGB32
+		     r = (c >> 16) & 255,
+		     g = (c >>  8) & 255,
+		     b = c        & 255;
+            PUT_PIXEL (ximg, x, y, lookup_rgb_color (f, r << 8, g << 8, b << 8));
                                    ^ returns BGRA32, or whatever windows uses.
+          }
+      image_put_x_image (f, img, ximg, 0);
+    }
+#endif

-- 
Alan Third
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.