wrbitmap.c - sam - An updated version of the sam text editor. | |
git clone git://vernunftzentrum.de/sam.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
wrbitmap.c (1439B) | |
--- | |
1 /* Copyright (c) 1998 Lucent Technologies - All rights reserved. */ | |
2 #include <u.h> | |
3 #include <libg.h> | |
4 #include "libgint.h" | |
5 #include <X11/Intrinsic.h> | |
6 | |
7 #include <stdio.h> | |
8 void | |
9 wrbitmap(Bitmap *b, int miny, int maxy, unsigned char *data) | |
10 { | |
11 XImage *im; | |
12 int w, h, inld, outld, l, offset, px; | |
13 GC g; | |
14 char *tdata; | |
15 | |
16 w = Dx(b->r); | |
17 h = maxy - miny; | |
18 inld = b->ldepth; | |
19 outld = (b->ldepth == 0) ? 0 : screen.ldepth; | |
20 px = 1<<(3-outld); /* pixels per byte */ | |
21 /* set l to number of bytes of data per scan line */ | |
22 if(b->r.min.x >= 0) | |
23 offset = b->r.min.x % px; | |
24 else | |
25 offset = px - b->r.min.x % px; | |
26 l = (-b->r.min.x+px-1)/px; | |
27 if(b->r.max.x >= 0) | |
28 l += (b->r.max.x+px-1)/px; | |
29 else | |
30 l -= b->r.max.x/px; | |
31 l *= h; | |
32 | |
33 tdata = (char *)malloc(l); | |
34 if (tdata == (char *) 0) | |
35 berror("wrbitmap malloc"); | |
36 if (inld == outld) | |
37 memcpy((void*)tdata, (void*)data, l); | |
38 else | |
39 _ldconvert((char*)data, inld, tdata, outld, w, h); | |
40 | |
41 im = XCreateImage(_dpy, 0, 1 << outld, ZPixmap, 0, tdata, w, h, 8, 0… | |
42 | |
43 /* Botched interface to XCreateImage doesn't let you set these: */ | |
44 im->bitmap_bit_order = MSBFirst; | |
45 im->byte_order = MSBFirst; | |
46 | |
47 g = _getfillgc(S, b, ~0); | |
48 XSetBackground(_dpy, g, b->flag&DP1 ? 0 : _bgpixel); | |
49 XPutImage(_dpy, (Drawable)b->id, g, im, offset, 0, 0, miny - b->r.mi… | |
50 XDestroyImage(im); | |
51 } |