From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Jan D." Newsgroups: gmane.emacs.devel Subject: Re: Help fix this: Bug in sliced XPM images on X -- bad clip mask origin. Date: Thu, 17 Jun 2004 21:41:07 +0200 (CEST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040617194144.LTHX26240.mxfep02.bredband.com@coolsville.localdomain> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1087501374 22181 80.91.224.253 (17 Jun 2004 19:42:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 17 Jun 2004 19:42:54 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Jun 17 21:42:34 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Bb2mP-0003uT-00 for ; Thu, 17 Jun 2004 21:42:33 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Bb2mP-0001Fs-00 for ; Thu, 17 Jun 2004 21:42:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bb2nS-0008P9-NZ for emacs-devel@quimby.gnus.org; Thu, 17 Jun 2004 15:43:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Bb2ms-000885-RY for emacs-devel@gnu.org; Thu, 17 Jun 2004 15:43:02 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Bb2mq-00086l-T1 for emacs-devel@gnu.org; Thu, 17 Jun 2004 15:43:01 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bb2mq-00085m-JH for emacs-devel@gnu.org; Thu, 17 Jun 2004 15:43:00 -0400 Original-Received: from [195.54.107.73] (helo=mxfep02.bredband.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Bb2ld-0007m5-Vv for emacs-devel@gnu.org; Thu, 17 Jun 2004 15:41:46 -0400 Original-Received: from coolsville.localdomain ([213.115.26.74] [213.115.26.74]) by mxfep02.bredband.com with ESMTP id <20040617194144.LTHX26240.mxfep02.bredband.com@coolsville.localdomain>; Thu, 17 Jun 2004 21:41:44 +0200 In-Reply-To: "from Kim F. Storm at Jun 4, 2004 00:15:50 am" Original-To: "Kim F. Storm" X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:25068 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25068 > > Some time ago I installed changes to support image slices, and > it works fine with e.g. png. > > However, there are severe problems with sliced XPM images, at least on X. > > The clip mask for each slice is taken from top/leftmost part of the > image, rather than the actual slice of the image. I have tried a > zillion things to setup the clip mask (and rewrite other parts of the > code) to make this work, but to no avail. > > So I hereby ask for help from more skilled X people. How do you setup > the clip mask of an image with an image mask so that XCopyArea will > use the corresponding part of the image mask when copying a slice from > the image ? > > Here is some code to illustrate the bug: > > (progn > (setq im2 (find-image '((:type xpm :file "gnus.xpm")))) > (insert "\n") > (insert-image im2) > (insert "\n") > (insert-sliced-image im2 nil nil 5 4) > (insert "\n")) The thing to remember is that the clip_origin in the GC is relative to the destination, never the source. So in effect, a XCopyArea first puts the mask on the destination at (clip_x, clip_y). Then it copies the bits from the source to the destination, where the mask is non-zero. So if you want to use part of the mask that starts at mask coordinates (x, y), you set (clip_x_origin, clip_y_origin) to (-x, -y) in the GC. Not the most intuitive thing to do, but that's the way it is. I've checked in the following patch, it makes the above test case work OK. However, there seems to be more code that deals with slices, so there may be other parts thats need this kind of modification also. Jan D. Index: xterm.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/xterm.c,v retrieving revision 1.837 retrieving revision 1.838 diff -c -c -r1.837 -r1.838 *** xterm.c 16 Jun 2004 15:07:20 -0000 1.837 --- xterm.c 17 Jun 2004 19:35:00 -0000 1.838 *************** *** 2357,2364 **** XGCValues xgcv; xgcv.clip_mask = s->img->mask; ! xgcv.clip_x_origin = x; ! xgcv.clip_y_origin = y; xgcv.function = GXcopy; XChangeGC (s->display, s->gc, mask, &xgcv); --- 2357,2364 ---- XGCValues xgcv; xgcv.clip_mask = s->img->mask; ! xgcv.clip_x_origin = x - s->slice.x; ! xgcv.clip_y_origin = y - s->slice.y; xgcv.function = GXcopy; XChangeGC (s->display, s->gc, mask, &xgcv);