unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Evgeny Zajcev <lg.zevlg@gmail.com>
Cc: 59242@debbugs.gnu.org, Stefan Kangas <stefankangas@gmail.com>
Subject: bug#59242: 29.0.50; Poor quality for WebP images
Date: Sun, 13 Nov 2022 17:44:22 +0800	[thread overview]
Message-ID: <877czzkx3d.fsf@yahoo.com> (raw)
In-Reply-To: <CAO=W_ZrcDXrSGUh41VaXRX4s0_Ns3gMk+j2U5h4-PjDdsit=gQ@mail.gmail.com> (Evgeny Zajcev's message of "Sun, 13 Nov 2022 11:48:01 +0300")

Evgeny Zajcev <lg.zevlg@gmail.com> writes:

> WebP images with alpha channel renders in poor quality in the Emacs.
> See http://lgarc.narod.ru/pics/emacs-webp-poor-quality.png
>
> If I convert webp image to png, quality is ok in resulting image.
> Also, if I add webp as native image under MacOS (requires Emacs patch)
> then quality is also ok.
>
> Looks like partial transparency is incorrectly applied for webp images.

Stefan, I see the following code in image.c:

	  /* An alpha channel associates variable transparency with an
	     image.  WebP allows up to 256 levels of partial transparency.
	     We handle this like with PNG (which see), using the frame's
	     background color to combine the image with.  */
	  if (features.has_alpha || anim)
	    {
	      if (mask_img)
		PUT_PIXEL (mask_img, x, y, *p > 0 ? PIX_MASK_DRAW : PIX_MASK_RETAIN);

however, you seem to have misunderstood the meaning of the PNG code: PNG
images can either have a real alpha channel (where the PNG library does
the blending AFAIK) or a simple on-off transparency switch, which is the
only case where this kind of masking is appropriate.

As a questionable optimization, Emacs also uses masking when only alpha
channels of 0 or 255 are present in a PNG image that has a real alpha
channel.

So if the webp library does not blend itself, I think we will have to do
that for it.  Am I missing anything here?





  reply	other threads:[~2022-11-13  9:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-13  8:48 bug#59242: 29.0.50; Poor quality for WebP images Evgeny Zajcev
2022-11-13  9:44 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-08-14  0:11   ` Stefan Kangas
2023-08-14  2:33     ` Eli Zaretskii
2023-08-14  7:08       ` Stefan Kangas
2023-08-25 18:28     ` Stefan Kangas

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=877czzkx3d.fsf@yahoo.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=59242@debbugs.gnu.org \
    --cc=lg.zevlg@gmail.com \
    --cc=luangruo@yahoo.com \
    --cc=stefankangas@gmail.com \
    /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).