From e39130cda16e3de89836005c70650077a5ffc4ce Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 13 Oct 2006 03:51:25 +0000 Subject: remove the horribly incorrect XImage handling and replace it with something much simpler that won't corrupt memory. --- xlib.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/xlib.c b/xlib.c index c0e669d..36d1012 100644 --- a/xlib.c +++ b/xlib.c @@ -79,11 +79,10 @@ int uudisp_open(struct uudisp *d) char *s; int px_w, px_h; struct ucf *f = d->font; - const unsigned char *glyphs, *end; int nglyphs = f->nglyphs; GC gc; int npages; - XImage *image; + XImage image; int i, j, k; int margin = 2; @@ -137,19 +136,7 @@ int uudisp_open(struct uudisp *d) npages = (nglyphs+1023) / 1024; // allows up to 64 pixel cell height.. p->glyph_cache = calloc(sizeof(p->glyph_cache[0]), npages); - glyphs = f->glyphs; - end = glyphs + nglyphs*f->S; - for (i=0; iS], *g = data; - - if (BitmapBitOrder(p->display) == LSBFirst) { - memset(data, 0, sizeof data); - for (k=0; k>(7-j))&1)<glyphs; - p->glyph_cache[i] = XCreatePixmap(p->display, DefaultRootWindow(p->display), d->cell_w, d->cell_h * 1024, 1); @@ -157,15 +144,23 @@ int uudisp_open(struct uudisp *d) gc = XCreateGC(p->display, p->glyph_cache[i], 0, &values); XSetForeground(p->display, gc, WhitePixel(p->display, p->screen)); XSetBackground(p->display, gc, BlackPixel(p->display, p->screen)); - XMatchVisualInfo(p->display, p->screen, 1, StaticGray, &vi); - image = XCreateImage(p->display, - vi.visual, 1, XYBitmap, (-d->cell_w)&7, g, d->cell_w, - d->cell_h*(i+1display, p->glyph_cache[i], gc, image, - 0, 0, 0, 0, d->cell_w, d->cell_h * 1024); + memset(&image, 0, sizeof image); + image.width = d->cell_w; + image.height = d->cell_h * 1024; + image.xoffset = (-d->cell_w)&7; + image.format = XYBitmap; + image.data = (void *)(f->glyphs + i*1024*f->S); + image.byte_order = ImageByteOrder(p->display); + image.bitmap_bit_order = MSBFirst; + image.bitmap_pad = 8; + image.depth = 1; + image.bytes_per_line = (d->cell_w+7)>>3; + XInitImage(&image); + XPutImage(p->display, p->glyph_cache[i], gc, &image, + 0, 0, 0, 0, d->cell_w, + d->cell_h*(i+1display, gc); } -- cgit v1.2.1