unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jan D." <jan.h.d@swipnet.se>
Cc: emacs-devel@gnu.org
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)	[thread overview]
Message-ID: <20040617194144.LTHX26240.mxfep02.bredband.com@coolsville.localdomain> (raw)
In-Reply-To: <m3oeo0b84p.fsf@kfs-l.imdomain.dk> "from Kim F. Storm at Jun 4, 2004 00:15:50 am"

> 
> 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);

  parent reply	other threads:[~2004-06-17 19:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-03 22:15 Help fix this: Bug in sliced XPM images on X -- bad clip mask origin Kim F. Storm
2004-06-03 22:45 ` Jason Rumney
2004-06-04  1:29   ` YAMAMOTO Mitsuharu
2004-06-04  8:00     ` Kim F. Storm
2004-06-17 19:41 ` Jan D. [this message]
2004-06-18  7:58   ` Kim F. Storm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040617194144.LTHX26240.mxfep02.bredband.com@coolsville.localdomain \
    --to=jan.h.d@swipnet.se \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).