From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#26133: [PATCH] Fix XBM files on NS (bug#26133) Date: Fri, 6 Dec 2019 17:01:56 +0000 Message-ID: <20191206170156.GA42203@breton.holly.idiocy.org> References: <20191206125605.GA38878@breton.holly.idiocy.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="233544"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.12.0 (2019-05-25) Cc: 26133@debbugs.gnu.org To: Devon Sean McCullough Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 06 19:25:45 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1idIIS-000yc3-Kr for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Dec 2019 19:25:44 +0100 Original-Received: from localhost ([::1]:43384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1idIIR-0000GF-1b for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Dec 2019 13:25:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34303) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1idH0S-00012z-JT for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 12:03:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1idH0R-0007md-1U for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 12:03:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41015) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1idH0Q-0007la-PJ for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 12:03:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1idH0Q-0007cS-Mk for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 12:03:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Dec 2019 17:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26133 X-GNU-PR-Package: emacs Original-Received: via spool by 26133-submit@debbugs.gnu.org id=B26133.157565173329036 (code B ref 26133); Fri, 06 Dec 2019 17:03:02 +0000 Original-Received: (at 26133) by debbugs.gnu.org; 6 Dec 2019 17:02:13 +0000 Original-Received: from localhost ([127.0.0.1]:46981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1idGza-0007Y5-0m for submit@debbugs.gnu.org; Fri, 06 Dec 2019 12:02:13 -0500 Original-Received: from mail-wr1-f68.google.com ([209.85.221.68]:46450) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1idGzV-0007Wo-Vw for 26133@debbugs.gnu.org; Fri, 06 Dec 2019 12:02:09 -0500 Original-Received: by mail-wr1-f68.google.com with SMTP id z7so8470810wrl.13 for <26133@debbugs.gnu.org>; Fri, 06 Dec 2019 09:02:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=fvv5rZMZHXQY4NrWsFd/QCZFpvi8m22A6dK1i7ZrxaA=; b=gYosJRjOJsETEVhgGrEhgDibaagnmunaOxAaoTAi0PGunlB4Sbo0t6q1qCQQYQGKjE aMBUVrbrJqWGZMkpvX1JzCnECvnQ4PHKBaWBVrVLmX16UI6VdBSfjLbzCzAZBMxY58H5 iMLPuJuNyhBd05eW+dGKWhVx5N8I+61zZT26OGaYzSkxge0mhcAXvm7moQPtTnyPHhTN mFLEBveUMJ8WmBNVLcYHVuwPjELc5ijnopE+bvBRLRhDqbNIryGQeeRW6XknALa/71/N KnL9WrsDMugJXj9ciqOujNzoBQZc/EeOZ8/PNKCbQRooqmV0KcxYia6DymncRbR670Pe pi4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=fvv5rZMZHXQY4NrWsFd/QCZFpvi8m22A6dK1i7ZrxaA=; b=d1Ebsrt1546EHgxE83m2o09xbNa1yz6M28Sg6lYCnTxNH0OwKGyS4HBztT5FqINiDO kU8e3gLiDxTONz2cklC77tliQWiL25eKEon6WLzQo6HNOCzDF/YDgF6r2dk4YbQ9HhoZ 3QfJy2Iu56KEsFc9dj5tm9VeE3Y8tcERlYJps09RLBP9NhCrisCKuGUfQq3dxKziVuoC RHwGRBNAUYDGkjkeqS8zc6qb78MmRDUNVc79sHN0k/vKwFkFI6oRwI49cKLJApCoTkHS milMpmOYcwdwpjr+AvRoEVHDJEWjE+VMEEd3m7/8yXGm/hfQaJvQp484/uy4NFymhaz7 utDA== X-Gm-Message-State: APjAAAXvUu1j0WTjBRz1luxZji7YXbmCFDSfp5vgjXxHgkjRxl/QmrnE a82abOHucvcIp6sA3pPmYB5OluyC0/Y= X-Google-Smtp-Source: APXvYqywItm8yz5Ex51HXjeA5ZPhlIHFYmjFOotk2eb1+SZbyUlLXDteu4GaaaL14yh97DSFrbvNAw== X-Received: by 2002:adf:f508:: with SMTP id q8mr13729800wro.334.1575651719802; Fri, 06 Dec 2019 09:01:59 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-8586-a56f-eccc-754e.holly.idiocy.org. [2001:8b0:3f8:8129:8586:a56f:eccc:754e]) by smtp.gmail.com with ESMTPSA id o1sm17052234wrn.84.2019.12.06.09.01.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Dec 2019 09:01:59 -0800 (PST) Content-Disposition: inline In-Reply-To: <20191206125605.GA38878@breton.holly.idiocy.org> 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: 209.51.188.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:172976 Archived-At: Reinstate some of the functionality removed in commit 67a878f78f879ce534232408c34dd11f42dd802b. * src/nsimage.m (ns_image_from_XBM): Use new reverseBytes argument. ([EmacsImage initFromXBM:width:height:fg:bg:reverseBytes:]): Add ability to reverse the contents of each byte for use with XBMs, while still working with fringe bitmaps. * src/nsterm.h ([EmacsImage initFromXBM:width:height:fg:bg:reverseBytes:]): Modified function definition. * src/nsterm.m (ns_draw_fringe_bitmap): Use new reverseBytes argument. --- src/nsimage.m | 17 +++++++++++++---- src/nsterm.h | 3 ++- src/nsterm.m | 3 ++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/nsimage.m b/src/nsimage.m index e1408c77f5..25d3b2299c 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -52,7 +52,7 @@ Updated by Christian Limpach (chris@nice.ch) NSTRACE ("ns_image_from_XBM"); return [[EmacsImage alloc] initFromXBM: (unsigned char *) bits width: width height: height - fg: fg bg: bg]; + fg: fg bg: bg reverseBytes: YES]; } void * @@ -228,7 +228,8 @@ - (void)dealloc /* Create image from monochrome bitmap. If both FG and BG are 0 (black), set the background to white and make it transparent. */ - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h - fg: (unsigned long)fg bg: (unsigned long)bg + fg: (unsigned long)fg bg: (unsigned long)bg + reverseBytes: (BOOL)reverse { unsigned char *planes[5]; unsigned char bg_alpha = 0xff; @@ -252,6 +253,8 @@ - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h { /* Pull bits out to set the (bytewise) alpha mask. */ + unsigned char swt[16] = {0, 8, 4, 12, 2, 10, 6, 14, + 1, 9, 5, 13, 3, 11, 7, 15}; int i, j, k; unsigned char *s = bits; unsigned char *rr = planes[0]; @@ -266,11 +269,18 @@ - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h unsigned char bgb = bg & 0xff; unsigned char c; - int idx = 0; for (j = 0; j < h; ++j) for (i = 0; i < w; ) { c = *s++; + + /* XBM files have the bits in reverse order within each byte + as compared to our fringe bitmaps. This function deals + with both so has to be able to handle the bytes in either + order. */ + if (reverse) + c = swt[c >> 4] | (swt[c & 0xf] << 4); + for (k = 0; i < w && k < 8; ++k, ++i) { if (c & 0x80) @@ -287,7 +297,6 @@ - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h *bb++ = bgb; *alpha++ = bg_alpha; } - idx++; c <<= 1; } } diff --git a/src/nsterm.h b/src/nsterm.h index 9773eb3e66..3803009afa 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -639,7 +639,8 @@ #define NSTRACE_UNSILENCE() + (instancetype)allocInitFromFile: (Lisp_Object)file; - (void)dealloc; - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h - fg: (unsigned long)fg bg: (unsigned long)bg; + fg: (unsigned long)fg bg: (unsigned long)bg + reverseBytes: (BOOL)reverse; - (instancetype)setXBMColor: (NSColor *)color; - (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: (int)height; - (void)setPixmapData; diff --git a/src/nsterm.m b/src/nsterm.m index 71234ac783..369b1173d8 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3106,7 +3106,8 @@ so some key presses (TAB) are swallowed by the system. */ cbits[i] = bits[i]; img = [[EmacsImage alloc] initFromXBM: cbits width: 8 height: full_height - fg: 0 bg: 0]; + fg: 0 bg: 0 + reverseBytes: NO]; bimgs[p->which - 1] = img; xfree (cbits); } -- 2.21.0 -- Alan Third