File: copymasked.c

package info (click to toggle)
sam 4.3-9
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,416 kB
  • ctags: 1,660
  • sloc: ansic: 14,329; makefile: 204; sh: 189
file content (47 lines) | stat: -rw-r--r-- 1,108 bytes parent folder | download | duplicates (20)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <libc.h>
#include <libg.h>
#include "libgint.h"

/*
 * m should be a 1-bit-deep bitmap with origin (0,0) and the
 * same extents as r.  s should have the same depth as d.
 * Rectangle r of s is copied to d wherever corresponding
 * bits of m are 1
 */
void
copymasked(Bitmap *d, Point p, Bitmap *s, Bitmap *m, Rectangle r)
{
	int sx, sy, dx, dy;
	XGCValues gcv;
	GC g;

	if(Dx(r)<=0 || Dy(r)<=0)
		return;
	sx = r.min.x;
	sy = r.min.y;
	if(s->flag&SHIFT){
		sx -= s->r.min.x;
		sy -= s->r.min.y;
	}
	dx = p.x;
	dy = p.y;
	if(d->flag&SHIFT){
		dx -= d->r.min.x;
		dy -= d->r.min.y;
	}
	gcv.fill_style = FillStippled;
	gcv.stipple = (Pixmap)m->id;
	gcv.function = GXclear;
	gcv.ts_x_origin = dx;
	gcv.ts_y_origin = dy;
	gcv.fill_style = FillStippled;
	g = _getgc(d, GCFunction|GCStipple|GCTileStipXOrigin
		|GCTileStipYOrigin|GCFillStyle, &gcv);
	XFillRectangle(_dpy, (Drawable)d->id, g,
			dx, dy, Dx(r), Dy(r));
	gcv.function = GXor;
	gcv.fill_style = FillSolid;
	g = _getgc(d, GCFunction|GCFillStyle, &gcv);
	XCopyArea(_dpy, (Drawable)s->id, (Drawable)d->id, g,
			sx, sy, Dx(r), Dy(r), dx, dy);
}