From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.bugs Subject: bug#28824: 26.0.90; display of pbm images broken? Date: Sun, 15 Oct 2017 18:42:27 +0100 Message-ID: <86wp3w48ak.fsf@gmail.com> References: <29226.45866.855134.23009@gargle.gargle.HOWL> <83376mjjq7.fsf@gnu.org> <34582.83757.771697.23010@gargle.gargle.HOWL> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1508089462 7580 195.159.176.226 (15 Oct 2017 17:44:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 15 Oct 2017 17:44:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt) To: 28824@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 15 19:44:14 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e3mxO-0008Uo-AL for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 Oct 2017 19:44:10 +0200 Original-Received: from localhost ([::1]:57953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e3mxQ-0003oF-JK for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 Oct 2017 13:44:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e3mxJ-0003oA-J5 for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 13:44:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e3mxG-0004JR-Fg for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 13:44:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33164) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e3mxG-0004Iz-BX for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 13:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e3mxG-0004eA-4g for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 13:44:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <29226.45866.855134.23009@gargle.gargle.HOWL> Resent-From: Andy Moreton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Oct 2017 17:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28824 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.150808938217771 (code B ref -1); Sun, 15 Oct 2017 17:44:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Oct 2017 17:43:02 +0000 Original-Received: from localhost ([127.0.0.1]:41845 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e3mwI-0004cO-1D for submit@debbugs.gnu.org; Sun, 15 Oct 2017 13:43:02 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52809) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e3mwG-0004c2-Id for submit@debbugs.gnu.org; Sun, 15 Oct 2017 13:43:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e3mw9-0003IZ-P5 for submit@debbugs.gnu.org; Sun, 15 Oct 2017 13:42:55 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:36042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e3mw9-0003Hw-Lq for submit@debbugs.gnu.org; Sun, 15 Oct 2017 13:42:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e3mw8-0003lG-Bn for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 13:42:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e3mw5-0003C1-87 for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 13:42:52 -0400 Original-Received: from [195.159.176.226] (port=40966 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e3mw5-00039z-0B for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 13:42:49 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1e3mvn-0004jn-Q6 for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 19:42:31 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 93 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:PTZeGywNRe4T5QKG7J7dTt4y6NE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:138468 Archived-At: On Sat 14 Oct 2017, Roland Winkler wrote: > On Sat Oct 14 2017 Eli Zaretskii wrote: >> Works for me in Emacs 26.0.90 on MS-Windows. I used PBM images from >> etc/images/ in the Emacs tree: does this fail to work for you with >> those images as well? > > I need to apologize: the bug is not with pbm images, but with ppm > images. (The tool I use to create them calls them pbm, but it gives > ppm, pgm or pbm files depending on the content of the image.) No problem - it lead me to find a different bug that also needed fixing. > $ identify home* > home-1bit.ppm PPM 24x24 24x24+0+0 1-bit sRGB 1.84KB 0.000u 0:00.000 > home-8bit.ppm PPM 24x24 24x24+0+0 8-bit sRGB 1.78KB 0.000u 0:00.000 > > PS: Visiting these files display them fine (according to the > modeline, this uses imagemagick). The problem occurs with > insert-image which appears to process these files differently Thanks for the example files. On Windows with a 64bit MSYS2 build of emacs 26 I also see the problems loading the home-8bit.ppm file. After some debugging, it appears that the problem was introduced in: commit 3c2c50260e19deff2a0a054882eaea4049f25a2f Author: Paul Eggert Date: Thu Sep 29 20:09:37 2016 -0700 This changed the raster data from using "unsigned char" to "char" which cannot be correct, as this is binary data. The trouble occurs when reading an 0xff byte from the raster data, which gets sign extended to r, g and b values (of type int) of -1. The following patch works for me (including the earlier fix): diff --git a/lisp/image.el b/lisp/image.el index 1d0776180b..32df508bc8 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -34,8 +34,8 @@ 'image-refresh (defconst image-type-header-regexps `(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm) ("\\`P[1-6]\\(?:\ -\\(?:\\(?:#[^\r\n]*[\r\n]\\)?[[:space:]]\\)+\ -\\(?:\\(?:#[^\r\n]*[\r\n]\\)?[0-9]\\)+\ +\\(?:\\(?:#[^\r\n]*[\r\n]\\)*[[:space:]]\\)+\ +\\(?:\\(?:#[^\r\n]*[\r\n]\\)*[0-9]\\)+\ \\)\\{2\\}" . pbm) ("\\`GIF8[79]a" . gif) ("\\`\x89PNG\r\n\x1a\n" . png) diff --git a/src/image.c b/src/image.c index 3dac7086cb..1d81da2663 100644 --- a/src/image.c +++ b/src/image.c @@ -5523,23 +5523,23 @@ pbm_load (struct frame *f, struct image *img) if (type == PBM_GRAY && raw_p) { - r = g = b = *p++; + r = g = b = *(uint8_t *) p++; if (max_color_idx > 255) - r = g = b = r * 256 + *p++; + r = g = b = r * 256 + *(uint8_t *) p++; } else if (type == PBM_GRAY) r = g = b = pbm_scan_number (&p, end); else if (raw_p) { - r = *p++; + r = *(uint8_t *) p++; if (max_color_idx > 255) - r = r * 256 + *p++; - g = *p++; + r = r * 256 + *(uint8_t *) p++; + g = *(uint8_t *) p++; if (max_color_idx > 255) - g = g * 256 + *p++; - b = *p++; + g = g * 256 + *(uint8_t *) p++; + b = *(uint8_t *) p++; if (max_color_idx > 255) - b = b * 256 + *p++; + b = b * 256 + *(uint8_t *) p++; } else { Eli can decide if reverting the previous "unsigned char" -> "char" changes is a better fix. AndyM