diff options
-rw-r--r-- | do_blt.c | 30 | ||||
-rw-r--r-- | do_tests.c | 24 |
2 files changed, 52 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) { @@ -1189,6 +1189,18 @@ Test test[] = { InitPutImage, DoPutImage, MidCopyPix, EndGetImage, V1_4FEATURE, ROP, 0, {4, 500, "XY"}}, + {"-putimagexybitmap10", "PutImage XYBitmap 10x10 square", NULL, + InitPutImage, DoPutImage, MidCopyPix, EndGetImage, + V1_4FEATURE, ROP, 0, + {4, 10, "XYBitmap"}}, + {"-putimagexybitmap100", "PutImage XYBitmap 100x100 square", NULL, + InitPutImage, DoPutImage, MidCopyPix, EndGetImage, + V1_4FEATURE, ROP, 0, + {4, 100, "XYBitmap"}}, + {"-putimagexybitmap500", "PutImage XYBitmap 500x500 square", NULL, + InitPutImage, DoPutImage, MidCopyPix, EndGetImage, + V1_4FEATURE, ROP, 0, + {4, 500, "XYBitmap"}}, #ifdef MITSHM {"-shmput10", "ShmPutImage 10x10 square", NULL, InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage, @@ -1214,6 +1226,18 @@ Test test[] = { InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage, V1_4FEATURE, ROP, 0, {4, 500, "XY"}}, + {"-shmputxybitmap10", "ShmPutImage XYBitmap 10x10 square", NULL, + InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage, + V1_4FEATURE, ROP, 0, + {4, 10, "XYBitmap"}}, + {"-shmputxybitmap100", "ShmPutImage XYBitmap 100x100 square", NULL, + InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage, + V1_4FEATURE, ROP, 0, + {4, 100, "XYBitmap"}}, + {"-shmputxybitmap500", "ShmPutImage XYBitmap 500x500 square", NULL, + InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage, + V1_4FEATURE, ROP, 0, + {4, 500, "XYBitmap"}}, {"-shmget10", "ShmGetImage 10x10 square", NULL, InitShmGetImage, DoShmGetImage, NullProc, EndShmGetImage, V1_2FEATURE, ROP, 0, |