unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Qiutum <zh4710jj@gmail.com>
To: 67968@debbugs.gnu.org
Subject: bug#67968: [PATCH] A small patch to make emacs support transparent image (png, webp, svg)
Date: Fri, 22 Dec 2023 19:38:09 +0800	[thread overview]
Message-ID: <CACph+bVEiGK7Mcd1JmsEEN403u=i=cTQagzCemp_tc7wKQtG0w@mail.gmail.com> (raw)
In-Reply-To: <CACph+bW99OiFn2c_yWy_vE3nw90ZLwmPES-uCuu=JYdQtHhubQ@mail.gmail.com>


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

Hi everyone,

Recently, I've been reading the code of image.c and wondering how to make
emacs support transparent image. Then I find that a small change on the
src/image.c can make it worked (and wonder why this have not been solved
since the solution is so simple).

This patch can support the transparent png, webp and svg. The core of the
patch is to change the code,

 PUT_PIXEL (mask_img, x, y, *p > 0 ? PIX_MASK_DRAW : PIX_MASK_RETAIN);

to

 PUT_PIXEL (mask_img, x, y, *p > 0 ? *p : PIX_MASK_RETAIN);

Then all worked like a magic.

I have checked my patch in linux by default configure option "../configure"
for dwm and pgtk build for hyprland, both are fine. I don't know whether it
could support other platforms since I don't have them.

Please check my patch and happy to hear comments.

Best regards,
Zhang

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

[-- Attachment #2: support-image-transparent.patch --]
[-- Type: application/x-patch, Size: 9393 bytes --]

       reply	other threads:[~2023-12-22 11:38 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 ` Qiutum [this message]
2023-12-24 14:36   ` bug#67968: [PATCH] A small patch to make emacs support transparent image (png, webp, svg) Stefan Kangas
2024-03-10 20:50   ` nsan

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='CACph+bVEiGK7Mcd1JmsEEN403u=i=cTQagzCemp_tc7wKQtG0w@mail.gmail.com' \
    --to=zh4710jj@gmail.com \
    --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).