From 2e11be1180a2e28504cf7c0d751a3966e1ead233 Mon Sep 17 00:00:00 2001 From: handa Date: Fri, 12 Mar 2004 13:03:05 +0000 Subject: [PATCH] *** empty log message *** --- src/m17n-X.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/m17n-X.c b/src/m17n-X.c index d9f7037..7ef4b42 100644 --- a/src/m17n-X.c +++ b/src/m17n-X.c @@ -1695,6 +1695,51 @@ mwin__draw_bitmap (MFrame *frame, MDrawWindow win, MRealizedFace *rface, XDrawPoint (display, (Window) win, gc, x + j, y + i); } +void +mwin__draw_pixmap (MFrame *frame, MDrawWindow win, MRealizedFace *rface, + int reverse, int x, int y, + int width, int height, int row_bytes, unsigned char *pmp, + MDrawRegion region) +{ + Display *display = FRAME_DISPLAY (frame); + int i, j; + GC *gcs = rface->info; + GC gc = gcs[reverse ? MFACE_GC_INVERSE : MFACE_GC_NORMAL]; + unsigned long valuemask = GCForeground | GCBackground; + XGCValues values; + XColor fore_color, back_color, color; + + if (region) + gc = set_region (FRAME_DISPLAY (frame), rface, gc, region); + + XGetGCValues (FRAME_DISPLAY (frame), gc, valuemask, &values); + fore_color.pixel = values.foreground; + back_color.pixel = values.background; + XQueryColor (FRAME_DISPLAY (frame), frame->device->cmap, &fore_color); + XQueryColor (FRAME_DISPLAY (frame), frame->device->cmap, &back_color); + + for (i = 0; i < height; i++, pmp += row_bytes) + for (j = 0; j < width; j++) + if (pmp[j]) + { + float ratio = (float) (pmp[j] >> 5) / 32; + + color = fore_color; + color.red = fore_color.red * ratio + back_color.red * (1 - ratio); + color.green = fore_color.green * ratio + back_color.green * (1 - ratio); + color.blue = fore_color.blue * ratio + back_color.blue * (1 - ratio); + if (XAllocColor (FRAME_DISPLAY (frame), frame->device->cmap, &color) + && fore_color.pixel != color.pixel) + { + XSetForeground (FRAME_DISPLAY (frame), gc, color.pixel); + fore_color.pixel = color.pixel; + } + XDrawPoint (display, (Window) win, gc, x + j, y + i); + } + if (fore_color.pixel != values.foreground) + XSetForeground (FRAME_DISPLAY (frame), gc, values.foreground); +} + MDrawRegion mwin__region_from_rect (MDrawMetric *rect) -- 1.7.10.4