From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Re: PNG pictures have gamma correction twice applied Date: Mon, 11 Nov 2002 11:58:13 -0500 Sender: emacs-devel-admin@gnu.org Message-ID: <200211111658.gABGwDC16585@rum.cs.yale.edu> References: <200211061556.gA6FuCU6005082@localhost.localdomain> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1037200730 18232 80.91.224.249 (13 Nov 2002 15:18:50 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 13 Nov 2002 15:18:50 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18BzCg-00048C-00 for ; Wed, 13 Nov 2002 16:13:18 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18BzOd-00066k-00 for ; Wed, 13 Nov 2002 16:25:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18BI7f-0002PK-00; Mon, 11 Nov 2002 12:13:15 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 18BHtP-0006L8-00 for emacs-devel@gnu.org; Mon, 11 Nov 2002 11:58:31 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 18BHtM-0006Jm-00 for emacs-devel@gnu.org; Mon, 11 Nov 2002 11:58:30 -0500 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by monty-python.gnu.org with esmtp (Exim 4.10) id 18BHtE-0006DP-00; Mon, 11 Nov 2002 11:58:20 -0500 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.11.6/8.11.6) id gABGwDC16585; Mon, 11 Nov 2002 11:58:13 -0500 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: David.Kastrup@t-online.de (David Kastrup) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:9310 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:9310 > 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. > entirely bypassed the whole folderol, and I would guess that for the > rest 10% of users with 8bit per pixel devices, some low quality > fallback (such as getting 64 fixed colors for 8bit display devices) > would still be appreciated more than the current slow behavior of > images. The reason for the "closest color" code is to deal with the situation where the aren't enough color slots available. There might very well not be 64 slots available. I think this part of the code is OK, especially since I believe it is only triggered in the very rare cases where it is needed. But I agree that the lookup&gamma&caching is a bit strangely done and is probably not ideal for displays with more than 256 colors. I believe the code for lookup has a comment that says essentially the same thing. But I also remember that some of that code was done to try and reduce the amount of X traffic (there were many calls to XAllocColor or XLookupColor or something like that). I think the caching could be improved (to reduce X traffic), tho. And bypassing this code for PNG would be a good idea since libpng should do a good enough (better) job already. Stefan