unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: nsan@posteo.de
To: 67968@debbugs.gnu.org
Subject: bug#67968: [PATCH] A small patch to make emacs support transparent image (png, webp, svg)
Date: Sun, 10 Mar 2024 20:50:33 +0000	[thread overview]
Message-ID: <3fb772f8deaa5a4a9de0f25f6c6996f9@posteo.de> (raw)
In-Reply-To: <CACph+bVEiGK7Mcd1JmsEEN403u=i=cTQagzCemp_tc7wKQtG0w@mail.gmail.com>

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

 

Hi Qiutum,

I can confirm that this patch works great on pgtk (sway). Thank you for
this!

Let me explain the problem it solves. The problem arises mostly for
users of the frame parameter alpha-background. Having set the
alpha-background sufficiently low, it becomes apparent that Emacs
doesn't *really* support transparency for these image types. Instead, it
either fills the background with the background color of the frame (png
& svg) or supports only a binary form of transparency (webp).

Here are some screenshots which show the difference, with
alpha-background set to 50 with
(set-frame-parameter nil 'alpha-background 50)

The svg is created with
(let ((svg (svg-create 100 100 :stroke-width 10)))
 (svg-circle svg 50 50 25 :fill "none" :stroke "black")
 (insert-image (svg-image svg)))

The png is the logo at
https://de.wikipedia.org/wiki/Portable_Network_Graphics and the webp is
the same image exported to webp.

 (I hope these images will show fine in the mailing list.)

SVG before (no transparency):

SVG after:

PNG before (note also that the G is rather gray instead of the correct
blue. The tint seems generally off due to the partial transparency of
the source):

PNG after:

webp before (note the binary transparency):

webp after partial transparency):

Best regards,
Nate

 

[-- Attachment #2.1: Type: text/html, Size: 2030 bytes --]

[-- Attachment #2.2: 0b5d9bc6.png --]
[-- Type: image/png, Size: 80093 bytes --]

[-- Attachment #2.3: 25e3531c.png --]
[-- Type: image/png, Size: 89982 bytes --]

[-- Attachment #2.4: 103f5ff5.png --]
[-- Type: image/png, Size: 37163 bytes --]

[-- Attachment #2.5: bbe58141.png --]
[-- Type: image/png, Size: 136647 bytes --]

[-- Attachment #2.6: 1006f992.png --]
[-- Type: image/png, Size: 89747 bytes --]

[-- Attachment #2.7: e747bf70.png --]
[-- Type: image/png, Size: 68822 bytes --]

      parent reply	other threads:[~2024-03-10 20:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CACph+bW99OiFn2c_yWy_vE3nw90ZLwmPES-uCuu=JYdQtHhubQ@mail.gmail.com>
2023-12-22 11:38 ` bug#67968: [PATCH] A small patch to make emacs support transparent image (png, webp, svg) Qiutum
2023-12-24 14:36   ` Stefan Kangas
2024-03-10 20:50   ` nsan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3fb772f8deaa5a4a9de0f25f6c6996f9@posteo.de \
    --to=nsan@posteo.de \
    --cc=67968@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).