diff options
Diffstat (limited to 'do_blt.c')
-rw-r--r-- | do_blt.c | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -215,11 +215,37 @@ InitImage(XParms xp, Parms p, int64_t reps, long pm) /* Create image to stuff bits into */ image = XGetImage(xp->d, xp->w, 0, 0, WIDTH, HEIGHT, pm, - p->font==NULL?ZPixmap:XYPixmap); + p->font==NULL ? ZPixmap : (strcmp(p->font, "XY") == 0? XYPixmap : ZPixmap)); if(image==NULL){ printf("XGetImage failed\n"); return False; } + if (p->font && !strcmp(p->font, "XYBitmap")) { + int bytes_per_line = (WIDTH + 31) / 8; + char *data = malloc (bytes_per_line * HEIGHT); + XImage *new = XCreateImage(xp->d, xp->vinfo.visual, 1, XYBitmap, 0, + data, WIDTH, HEIGHT, 32, bytes_per_line); + int x, y; + unsigned long zero_pixel; + int has_zero = 0; + + for (y = 0; y < HEIGHT; y++) + for (x = 0; x < WIDTH; x++) { + unsigned long src_pixel = XGetPixel(image, x, y); + unsigned long dst_pixel = 0; + if (!has_zero) { + zero_pixel = src_pixel; + has_zero = 1; + } + if (src_pixel == zero_pixel) + dst_pixel = 0; + else + dst_pixel = 1; + XPutPixel(new, x, y, dst_pixel); + } + XDestroyImage(image); + image = new; + } return reps; } @@ -394,7 +420,7 @@ InitShmImage(XParms xp, Parms p, int64_t reps, Bool read_only) shm_image = *image; image_size = image->bytes_per_line * image->height; /* allow XYPixmap choice: */ - if(p->font)image_size *= xp->vinfo.depth; + if(p->font && strcmp(p->font, "XYBitmap") != 0) image_size *= xp->vinfo.depth; shm_info.shmid = shmget(IPC_PRIVATE, image_size, IPC_CREAT|0777); if (shm_info.shmid < 0) { |