emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help fix this: Bug in sliced XPM images on X -- bad clip mask origin


From: Jan D.
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)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]