From unknown Mon Aug 18 22:11:44 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14969: XBM image properties :foreground :background do not work on OSX Resent-From: Willem Rein Oudshoorn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Jul 2013 23:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14969 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 14969@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.137496639818617 (code B ref -1); Sat, 27 Jul 2013 23:07:02 +0000 Received: (at submit) by debbugs.gnu.org; 27 Jul 2013 23:06:38 +0000 Received: from localhost ([127.0.0.1]:53495 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V3DZM-0004q8-Jx for submit@debbugs.gnu.org; Sat, 27 Jul 2013 19:06:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40324) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V3Bu8-0000nC-3D for submit@debbugs.gnu.org; Sat, 27 Jul 2013 17:19:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3Btw-00011R-SG for submit@debbugs.gnu.org; Sat, 27 Jul 2013 17:19:50 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-99.2 required=5.0 tests=BAYES_50,USER_IN_WHITELIST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:54616) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3Btw-00010y-N0 for submit@debbugs.gnu.org; Sat, 27 Jul 2013 17:19:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3Btr-0003T6-4s for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2013 17:19:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3Btl-0000pb-Pf for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2013 17:19:39 -0400 Received: from plane.gmane.org ([80.91.229.3]:49795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3AtP-0007Gd-2N for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2013 16:15:07 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V3AtM-0008Ey-5H for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2013 22:15:04 +0200 Received: from ironhead.xs4all.nl ([80.101.115.122]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 27 Jul 2013 22:15:04 +0200 Received: from woudshoo by ironhead.xs4all.nl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 27 Jul 2013 22:15:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ From: Willem Rein Oudshoorn Date: Sat, 27 Jul 2013 22:12:14 +0200 Lines: 224 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ironhead.xs4all.nl User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:BWiwh9OyqgbUaaNhChwv5b690Ts= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -2.4 (--) X-Mailman-Approved-At: Sat, 27 Jul 2013 19:06:35 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain As in the subject, the XBM image properties :foreground :background have no effect on OSX. This is easily tested with: ========= (defun make-test-image (foreground background) `(image :type xbm :data ,(let ((data (make-bool-vector (* 10 10) nil)) (index 0)) (while (< index (* 10 10)) (aset data index (= 0 (% index 3))) (setq index (+ 1 index))) data) :height 10 :width 10 :foreground ,foreground :background ,background)) (defun test-images () (interactive) (insert-image (make-test-image nil nil)) (insert-image (make-test-image "red" nil)) (insert-image (make-test-image nil "green")) (insert-image (make-test-image "blue" "orange"))) ========= After running `test-images' I expect differently colored images, but they are all monochrome. (black and white). After applying the following patch, it works for nextstep based terminal systems. I have tried to adher to the style already present in the file, and I do not the setup is the most elegant. But changing that would require a more intrusive patch. Wim Oudshoorn. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=xbm_color.patch Content-Description: Patch for nextstep terminal to support color XBM images === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-27 13:08:03 +0000 +++ src/ChangeLog 2013-07-27 20:04:19 +0000 @@ -1,3 +1,21 @@ +2013-07-27 Willem Rein Oudshoorn + + * nsterm.h: added declaration of new method and function. + + * nsimage.m (ns_image_convert_mono_to_color): New function to + set the background and foreground color of XBM bitmaps. + (setXBMColor:): Use new method + -setForegroundToRed:green:blue:alpha:andBackgroundToRed:green:blue:alpha:drawBackground: + + (setForegroundToRed:green:blue:alpha:andBackgroundToRed:green:blue:alpha:drawBackground:): + New method to set foreground and background colors in monochrome bitmaps. + + * image.c (Create_Pixmap_From_Bitmap_Data): Call + ns_image_convert_mono_to_color in case of non default colors, + similarly to the win32 code. This fixes the problem that the + :foreground and :background properties of XBM images are ignored + on nextstep like platforms. + 2013-07-27 Eli Zaretskii * w32term.c (w32_read_socket) : Call === modified file 'src/image.c' --- src/image.c 2013-07-20 19:20:33 +0000 +++ src/image.c 2013-07-27 16:00:08 +0000 @@ -2674,7 +2674,8 @@ #elif defined (HAVE_NS) img->pixmap = ns_image_from_XBM (data, img->width, img->height); - + if (non_default_colors) + ns_image_convert_mono_to_color (img->pixmap, fg, bg); #else img->pixmap = (x_check_image_size (0, img->width, img->height) === modified file 'src/nsimage.m' --- src/nsimage.m 2013-06-02 19:14:25 +0000 +++ src/nsimage.m 2013-07-27 19:59:19 +0000 @@ -151,6 +151,19 @@ [(EmacsImage *)img setAlphaAtX: x Y: y to: a]; } +void +ns_image_convert_mono_to_color (void *img, unsigned long fg_argb, unsigned long bg_argb) +{ + [(EmacsImage *)img setForegroundToRed: (fg_argb >> 16) & 0xFF + green: (fg_argb >> 8) & 0xFF + blue: fg_argb & 0xFF + alpha: (fg_argb >> 24) & 0xFF + andBackgroundToRed: (bg_argb >> 16) & 0xFF + green: (bg_argb >> 8) & 0xFF + blue: bg_argb & 0xFF + alpha: (bg_argb >> 24) & 0xFF + drawBackground: YES]; +} /* ========================================================================== @@ -328,12 +341,8 @@ } -/* Set color for a bitmap image (see initFromSkipXBM). Note that the alpha - is used as a mask, so we just memset the entire array. */ - setXBMColor: (NSColor *)color { - NSSize s = [self size]; - unsigned char *planes[5]; EmacsCGFloat r, g, b, a; NSColor *rgbColor; @@ -347,21 +356,12 @@ [rgbColor getRed: &r green: &g blue: &b alpha: &a]; - [bmRep getBitmapDataPlanes: planes]; - - /* we used to just do this, but Cocoa seems to have a bug when rendering - an alpha-masked image onto a dark background where it bloats the mask */ - /* memset (planes[0..2], r, g, b*0xff, len); */ { - int i, len = s.width*s.height; int rr = r * 0xff, gg = g * 0xff, bb = b * 0xff; - for (i =0; i Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 31 Jul 2013 11:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14969 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Willem Rein Oudshoorn Cc: 14969@debbugs.gnu.org Received: via spool by 14969-submit@debbugs.gnu.org id=B14969.13752713047079 (code B ref 14969); Wed, 31 Jul 2013 11:49:02 +0000 Received: (at 14969) by debbugs.gnu.org; 31 Jul 2013 11:48:24 +0000 Received: from localhost ([127.0.0.1]:60233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V4UtD-0001q6-OX for submit@debbugs.gnu.org; Wed, 31 Jul 2013 07:48:24 -0400 Received: from mail01.bdtv.se ([176.10.222.34]:50629) by debbugs.gnu.org with smtp (Exim 4.80) (envelope-from ) id 1V4UtA-0001pj-90 for 14969@debbugs.gnu.org; Wed, 31 Jul 2013 07:48:21 -0400 Received: (qmail 24314 invoked by uid 89); 31 Jul 2013 11:48:17 -0000 Received: from h-46-59-42-57.na.cust.bahnhof.se (HELO coolsville.localdomain) (boel.djarv@bdtv.se@46.59.42.57) by mail01.bdtv.se with ESMTPA; 31 Jul 2013 11:48:17 -0000 Received: from [172.20.199.2] (gaffa [172.20.199.2]) by coolsville.localdomain (Postfix) with ESMTPSA id 93C9C1A1D78; Wed, 31 Jul 2013 13:48:17 +0200 (CEST) Message-ID: <51F8F981.40903@swipnet.se> Date: Wed, 31 Jul 2013 13:48:17 +0200 From: "Jan D." User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) Hello. Can somebody say if this requires copyright assignment? Jan D. Willem Rein Oudshoorn skrev 2013-07-27 22:12: > As in the subject, the XBM image properties :foreground :background > have no effect on OSX. > > This is easily tested with: > > ========= > (defun make-test-image (foreground background) > `(image :type xbm > :data > ,(let ((data (make-bool-vector (* 10 10) nil)) > (index 0)) > (while (< index (* 10 10)) > (aset data index (= 0 (% index 3))) > (setq index (+ 1 index))) > data) > :height 10 > :width 10 > :foreground ,foreground > :background ,background)) > > > (defun test-images () > (interactive) > (insert-image (make-test-image nil nil)) > (insert-image (make-test-image "red" nil)) > (insert-image (make-test-image nil "green")) > (insert-image (make-test-image "blue" "orange"))) > ========= > > After running `test-images' I expect differently colored images, but > they are all monochrome. (black and white). > > After applying the following patch, it works for nextstep based terminal > systems. > > I have tried to adher to the style already present in the file, > and I do not the setup is the most elegant. But changing that > would require a more intrusive patch. > > > Wim Oudshoorn. > From unknown Mon Aug 18 22:11:44 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14969: XBM image properties :foreground :background do not work on OSX Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 31 Jul 2013 14:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14969 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: "Jan D." Cc: 14969@debbugs.gnu.org, Willem Rein Oudshoorn Received: via spool by 14969-submit@debbugs.gnu.org id=B14969.137528012332234 (code B ref 14969); Wed, 31 Jul 2013 14:16:02 +0000 Received: (at 14969) by debbugs.gnu.org; 31 Jul 2013 14:15:23 +0000 Received: from localhost ([127.0.0.1]:60997 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V4XBS-0008NF-Nl for submit@debbugs.gnu.org; Wed, 31 Jul 2013 10:15:23 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:2253) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V4XBQ-0008DH-2U for 14969@debbugs.gnu.org; Wed, 31 Jul 2013 10:15:20 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFpZvt/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM X-IPAS-Result: Av4EABK/CFFFpZvt/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="20244969" Received: from 69-165-155-237.dsl.teksavvy.com (HELO pastel.home) ([69.165.155.237]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 31 Jul 2013 10:15:08 -0400 Received: by pastel.home (Postfix, from userid 20848) id 1596A63C70; Wed, 31 Jul 2013 10:15:14 -0400 (EDT) From: Stefan Monnier Message-ID: References: <51F8F981.40903@swipnet.se> Date: Wed, 31 Jul 2013 10:15:14 -0400 In-Reply-To: <51F8F981.40903@swipnet.se> (Jan D.'s message of "Wed, 31 Jul 2013 13:48:17 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > Can somebody say if this requires copyright assignment? I think it does, yes. Stefan From unknown Mon Aug 18 22:11:44 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14969: XBM image properties :foreground :background do not work on OSX Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 31 Jul 2013 16:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14969 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: "Jan D." Cc: 14969@debbugs.gnu.org, Willem Rein Oudshoorn Received: via spool by 14969-submit@debbugs.gnu.org id=B14969.137528635519202 (code B ref 14969); Wed, 31 Jul 2013 16:00:02 +0000 Received: (at 14969) by debbugs.gnu.org; 31 Jul 2013 15:59:15 +0000 Received: from localhost ([127.0.0.1]:32870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V4Yny-0004zd-CV for submit@debbugs.gnu.org; Wed, 31 Jul 2013 11:59:14 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:37284 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V4Ynw-0004zR-BL for 14969@debbugs.gnu.org; Wed, 31 Jul 2013 11:59:12 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1V4Ynv-00078i-7H; Wed, 31 Jul 2013 11:59:11 -0400 From: Glenn Morris References: <51F8F981.40903@swipnet.se> X-Spook: Indigo Belknap analyzer benelux ISEC BLU-114/B anarchy X-Ran: iwmKowoN1;^%*kJ6&l@p(T9apYtTvZqV}k\NG\&,[Z(UwQuJYpGJ>k(9:uM5]k_'f X-Hue: magenta X-Attribution: GM Date: Wed, 31 Jul 2013 11:59:10 -0400 In-Reply-To: <51F8F981.40903@swipnet.se> (Jan D.'s message of "Wed, 31 Jul 2013 13:48:17 +0200") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.5 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.5 (------) "Jan D." wrote: > Can somebody say if this requires copyright assignment? I think so. Since the OP already said he was willing to complete one, I'll send the form off-list. From unknown Mon Aug 18 22:11:44 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Willem Rein Oudshoorn Subject: bug#14969: closed (Re: bug#14969: XBM image properties :foreground :background do not work on OSX) Message-ID: References: <5555BE1E.1070700@swipnet.se> X-Gnu-PR-Message: they-closed 14969 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 14969@debbugs.gnu.org Date: Fri, 15 May 2015 09:37:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1431682622-25197-1" This is a multi-part message in MIME format... ------------=_1431682622-25197-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #14969: XBM image properties :foreground :background do not work on OSX which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 14969@debbugs.gnu.org. --=20 14969: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D14969 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1431682622-25197-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 14969-done) by debbugs.gnu.org; 15 May 2015 09:36:39 +0000 Received: from localhost ([127.0.0.1]:45782 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YtC2p-0006Xn-87 for submit@debbugs.gnu.org; Fri, 15 May 2015 05:36:39 -0400 Received: from mailfe08.swip.net ([212.247.154.225]:38063 helo=swip.net) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YtC2n-0006XT-0U for 14969-done@debbugs.gnu.org; Fri, 15 May 2015 05:36:37 -0400 X-T2-Spam-Status: No, hits=0.8 required=5.0 tests=BAYES_50 Received: from hosdjarv.se (account mj138573@tele2.se [46.59.42.57] verified) by mailfe08.swip.net (CommuniGate Pro SMTP 5.4.4) with ESMTPA id 597595002; Fri, 15 May 2015 11:36:30 +0200 Message-ID: <5555BE1E.1070700@swipnet.se> Date: Fri, 15 May 2015 11:36:30 +0200 From: "Jan D." User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Glenn Morris Subject: Re: bug#14969: XBM image properties :foreground :background do not work on OSX References: <51F8F981.40903@swipnet.se> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 14969-done Cc: 14969-done@debbugs.gnu.org, Willem Rein Oudshoorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Glenn Morris skrev den 2013-07-31 17:59: > "Jan D." wrote: > >> Can somebody say if this requires copyright assignment? > > I think so. Since the OP already said he was willing to complete one, > I'll send the form off-list. > No assignment seen. I fixed this in a different way. Jan D. ------------=_1431682622-25197-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 27 Jul 2013 23:06:38 +0000 Received: from localhost ([127.0.0.1]:53495 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V3DZM-0004q8-Jx for submit@debbugs.gnu.org; Sat, 27 Jul 2013 19:06:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40324) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V3Bu8-0000nC-3D for submit@debbugs.gnu.org; Sat, 27 Jul 2013 17:19:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3Btw-00011R-SG for submit@debbugs.gnu.org; Sat, 27 Jul 2013 17:19:50 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-99.2 required=5.0 tests=BAYES_50,USER_IN_WHITELIST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:54616) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3Btw-00010y-N0 for submit@debbugs.gnu.org; Sat, 27 Jul 2013 17:19:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3Btr-0003T6-4s for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2013 17:19:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3Btl-0000pb-Pf for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2013 17:19:39 -0400 Received: from plane.gmane.org ([80.91.229.3]:49795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3AtP-0007Gd-2N for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2013 16:15:07 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V3AtM-0008Ey-5H for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2013 22:15:04 +0200 Received: from ironhead.xs4all.nl ([80.101.115.122]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 27 Jul 2013 22:15:04 +0200 Received: from woudshoo by ironhead.xs4all.nl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 27 Jul 2013 22:15:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: Willem Rein Oudshoorn Subject: XBM image properties :foreground :background do not work on OSX Date: Sat, 27 Jul 2013 22:12:14 +0200 Lines: 224 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ironhead.xs4all.nl User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:BWiwh9OyqgbUaaNhChwv5b690Ts= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 27 Jul 2013 19:06:35 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain As in the subject, the XBM image properties :foreground :background have no effect on OSX. This is easily tested with: ========= (defun make-test-image (foreground background) `(image :type xbm :data ,(let ((data (make-bool-vector (* 10 10) nil)) (index 0)) (while (< index (* 10 10)) (aset data index (= 0 (% index 3))) (setq index (+ 1 index))) data) :height 10 :width 10 :foreground ,foreground :background ,background)) (defun test-images () (interactive) (insert-image (make-test-image nil nil)) (insert-image (make-test-image "red" nil)) (insert-image (make-test-image nil "green")) (insert-image (make-test-image "blue" "orange"))) ========= After running `test-images' I expect differently colored images, but they are all monochrome. (black and white). After applying the following patch, it works for nextstep based terminal systems. I have tried to adher to the style already present in the file, and I do not the setup is the most elegant. But changing that would require a more intrusive patch. Wim Oudshoorn. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=xbm_color.patch Content-Description: Patch for nextstep terminal to support color XBM images === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-27 13:08:03 +0000 +++ src/ChangeLog 2013-07-27 20:04:19 +0000 @@ -1,3 +1,21 @@ +2013-07-27 Willem Rein Oudshoorn + + * nsterm.h: added declaration of new method and function. + + * nsimage.m (ns_image_convert_mono_to_color): New function to + set the background and foreground color of XBM bitmaps. + (setXBMColor:): Use new method + -setForegroundToRed:green:blue:alpha:andBackgroundToRed:green:blue:alpha:drawBackground: + + (setForegroundToRed:green:blue:alpha:andBackgroundToRed:green:blue:alpha:drawBackground:): + New method to set foreground and background colors in monochrome bitmaps. + + * image.c (Create_Pixmap_From_Bitmap_Data): Call + ns_image_convert_mono_to_color in case of non default colors, + similarly to the win32 code. This fixes the problem that the + :foreground and :background properties of XBM images are ignored + on nextstep like platforms. + 2013-07-27 Eli Zaretskii * w32term.c (w32_read_socket) : Call === modified file 'src/image.c' --- src/image.c 2013-07-20 19:20:33 +0000 +++ src/image.c 2013-07-27 16:00:08 +0000 @@ -2674,7 +2674,8 @@ #elif defined (HAVE_NS) img->pixmap = ns_image_from_XBM (data, img->width, img->height); - + if (non_default_colors) + ns_image_convert_mono_to_color (img->pixmap, fg, bg); #else img->pixmap = (x_check_image_size (0, img->width, img->height) === modified file 'src/nsimage.m' --- src/nsimage.m 2013-06-02 19:14:25 +0000 +++ src/nsimage.m 2013-07-27 19:59:19 +0000 @@ -151,6 +151,19 @@ [(EmacsImage *)img setAlphaAtX: x Y: y to: a]; } +void +ns_image_convert_mono_to_color (void *img, unsigned long fg_argb, unsigned long bg_argb) +{ + [(EmacsImage *)img setForegroundToRed: (fg_argb >> 16) & 0xFF + green: (fg_argb >> 8) & 0xFF + blue: fg_argb & 0xFF + alpha: (fg_argb >> 24) & 0xFF + andBackgroundToRed: (bg_argb >> 16) & 0xFF + green: (bg_argb >> 8) & 0xFF + blue: bg_argb & 0xFF + alpha: (bg_argb >> 24) & 0xFF + drawBackground: YES]; +} /* ========================================================================== @@ -328,12 +341,8 @@ } -/* Set color for a bitmap image (see initFromSkipXBM). Note that the alpha - is used as a mask, so we just memset the entire array. */ - setXBMColor: (NSColor *)color { - NSSize s = [self size]; - unsigned char *planes[5]; EmacsCGFloat r, g, b, a; NSColor *rgbColor; @@ -347,21 +356,12 @@ [rgbColor getRed: &r green: &g blue: &b alpha: &a]; - [bmRep getBitmapDataPlanes: planes]; - - /* we used to just do this, but Cocoa seems to have a bug when rendering - an alpha-masked image onto a dark background where it bloats the mask */ - /* memset (planes[0..2], r, g, b*0xff, len); */ { - int i, len = s.width*s.height; int rr = r * 0xff, gg = g * 0xff, bb = b * 0xff; - for (i =0; i