diff options
author | Robin Watts <robin.watts@artifex.com> | 2010-06-29 19:22:10 +0200 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2010-06-29 19:22:10 +0200 |
commit | d9661dcb35f70cbd5019db4320cd24d6dbae584a (patch) | |
tree | fc1ded7bb745b59bea485ccb0dce1f52c331bdb7 /apps/x11_main.c | |
parent | 1e36247e887afb83ab967d2415d076b69fdb1dd8 (diff) | |
download | mupdf-d9661dcb35f70cbd5019db4320cd24d6dbae584a.tar.xz |
Add key 'c' to toggle between color and greyscale in both X11 and Windows viewers.
Diffstat (limited to 'apps/x11_main.c')
-rw-r--r-- | apps/x11_main.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/apps/x11_main.c b/apps/x11_main.c index 59261f43..70d331bf 100644 --- a/apps/x11_main.c +++ b/apps/x11_main.c @@ -283,13 +283,38 @@ static void winblit(pdfapp_t *app) pdfapp_inverthit(&gapp); - ximage_blit(xwin, xgc, - x0, y0, - gapp.image->samples, - 0, 0, - gapp.image->w, - gapp.image->h, - gapp.image->w * gapp.image->n); + if (gapp.image->n == 4) + ximage_blit(xwin, xgc, + x0, y0, + gapp.image->samples, + 0, 0, + gapp.image->w, + gapp.image->h, + gapp.image->w * gapp.image->n); + else if (gapp.image->n == 2) + { + int i = gapp.image->w*gapp.image->h; + unsigned char *color = malloc(i*4); + if (color != NULL) + { + unsigned char *s = gapp.image->samples; + unsigned char *d = color; + for (; i > 0 ; i--) + { + d[0] = *s++; + d[3] = d[2] = d[1] = *s++; + d += 4; + } + ximage_blit(xwin, xgc, + x0, y0, + color, + 0, 0, + gapp.image->w, + gapp.image->h, + gapp.image->w * 4); + free(color); + } + } pdfapp_inverthit(&gapp); |