unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu>
Cc: "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu>,
	rms@gnu.org, emacs-devel@gnu.org
Subject: Re: PNG pictures have gamma correction twice applied
Date: Mon, 11 Nov 2002 12:43:50 -0500	[thread overview]
Message-ID: <200211111743.gABHhoA16796@rum.cs.yale.edu> (raw)
In-Reply-To: 200211111730.gABHUx7L010488@localhost.localdomain

> "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:
> 
> > > Now x_alloc_nearest_color is defined in src/xterm.c.  It first calls
> > > gamma_correct on the function in question (which does the gamma
> > > correction with a very expensive floating point operation), then
> > > calls x_alloc_nearest_color_1, which does a costly operation of
> > > figuring out a closest color.
> > 
> > Have you checked whether this "costly operation" is actually done
> > in your case ?  It should only happen if the XAllocColor fails, which
> > should never be the case in a 16bpp (or more) display.
> 
> Correction: which should not be the case when there is no palette
> involved of any kind.  If there is, XAllocColor will allocate the
> next free color slot.  Since the Emacs display code never deallocates
> a color again, the color palette will run out of colors eventually.
> Whatever colors happen to be in the palette at that time, get used
> for the "closest" color.  If you have, for example, a color diagram
> as an image, the red top will allocate all the colors away, and blue,
> green and white will be all represented by shades of red.

IIUC, the problem is not with the closest-match thing per se, but with
the fact that Emacs doesn't deallocate colors.  And that for images,
it's probably better to pre-allocate a set of colors and stick
to them, since most images will otherwise overflow the 256-color palette.
Agreed.  The code you're looking at was really meant for text originally.

> For that reason it would be more prudent to allocate a fixed palette,
> even if it has just 4x4x4 colors, and use that.

For images, yes.  For text, I don't see the need: I hate it when an
application allocates 64colors of my small colormap only to use 10 of them;
and doesn't even get them right because it approximates
within the 64 it pre-defined rather than using the exact color.

> Just making use of whatever happens to be present in the current palette
> is an emergency measure.

For some users, it's the "normal case" (many apps gobble up most/all the
colormap).

> And asking for the current palette again for every new
> pixel is not going to be reducing the X traffic...

That's the part of the caching which could be improved.


	Stefan "who cares about 256-color displays and Emacs displaying text
		much more than about Emacs displaying images"

  reply	other threads:[~2002-11-11 17:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200211061556.gA6FuCU6005082@localhost.localdomain>
2002-11-07 15:08 ` PNG pictures have gamma correction twice applied Richard Stallman
2002-11-09 22:40   ` David Kastrup
2002-11-11 10:20     ` Richard Stallman
2002-11-30 13:36       ` David Kastrup
2002-12-03 14:59         ` Richard Stallman
2002-12-03 15:21           ` David Kastrup
2002-12-05 15:08             ` Richard Stallman
2002-12-05 15:34               ` David Kastrup
2002-12-05 17:31               ` David Kastrup
2002-12-06 15:52                 ` Richard Stallman
2002-12-06 16:01                   ` David Kastrup
2002-11-11 16:58     ` Stefan Monnier
2002-11-11 17:30       ` David Kastrup
2002-11-11 17:43         ` Stefan Monnier [this message]
2002-11-18 11:31           ` David Kastrup

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=200211111743.gABHhoA16796@rum.cs.yale.edu \
    --to=monnier+gnu/emacs@rum.cs.yale.edu \
    --cc=emacs-devel@gnu.org \
    --cc=rms@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).