=== modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-27 13:08:03 +0000 +++ src/ChangeLog 2013-07-27 20:04:19 +0000 @@ -1,3 +1,21 @@ +2013-07-27 Willem Rein Oudshoorn + + * nsterm.h: added declaration of new method and function. + + * nsimage.m (ns_image_convert_mono_to_color): New function to + set the background and foreground color of XBM bitmaps. + (setXBMColor:): Use new method + -setForegroundToRed:green:blue:alpha:andBackgroundToRed:green:blue:alpha:drawBackground: + + (setForegroundToRed:green:blue:alpha:andBackgroundToRed:green:blue:alpha:drawBackground:): + New method to set foreground and background colors in monochrome bitmaps. + + * image.c (Create_Pixmap_From_Bitmap_Data): Call + ns_image_convert_mono_to_color in case of non default colors, + similarly to the win32 code. This fixes the problem that the + :foreground and :background properties of XBM images are ignored + on nextstep like platforms. + 2013-07-27 Eli Zaretskii * w32term.c (w32_read_socket) : Call === modified file 'src/image.c' --- src/image.c 2013-07-20 19:20:33 +0000 +++ src/image.c 2013-07-27 16:00:08 +0000 @@ -2674,7 +2674,8 @@ #elif defined (HAVE_NS) img->pixmap = ns_image_from_XBM (data, img->width, img->height); - + if (non_default_colors) + ns_image_convert_mono_to_color (img->pixmap, fg, bg); #else img->pixmap = (x_check_image_size (0, img->width, img->height) === modified file 'src/nsimage.m' --- src/nsimage.m 2013-06-02 19:14:25 +0000 +++ src/nsimage.m 2013-07-27 19:59:19 +0000 @@ -151,6 +151,19 @@ [(EmacsImage *)img setAlphaAtX: x Y: y to: a]; } +void +ns_image_convert_mono_to_color (void *img, unsigned long fg_argb, unsigned long bg_argb) +{ + [(EmacsImage *)img setForegroundToRed: (fg_argb >> 16) & 0xFF + green: (fg_argb >> 8) & 0xFF + blue: fg_argb & 0xFF + alpha: (fg_argb >> 24) & 0xFF + andBackgroundToRed: (bg_argb >> 16) & 0xFF + green: (bg_argb >> 8) & 0xFF + blue: bg_argb & 0xFF + alpha: (bg_argb >> 24) & 0xFF + drawBackground: YES]; +} /* ========================================================================== @@ -328,12 +341,8 @@ } -/* Set color for a bitmap image (see initFromSkipXBM). Note that the alpha - is used as a mask, so we just memset the entire array. */ - setXBMColor: (NSColor *)color { - NSSize s = [self size]; - unsigned char *planes[5]; EmacsCGFloat r, g, b, a; NSColor *rgbColor; @@ -347,21 +356,12 @@ [rgbColor getRed: &r green: &g blue: &b alpha: &a]; - [bmRep getBitmapDataPlanes: planes]; - - /* we used to just do this, but Cocoa seems to have a bug when rendering - an alpha-masked image onto a dark background where it bloats the mask */ - /* memset (planes[0..2], r, g, b*0xff, len); */ { - int i, len = s.width*s.height; int rr = r * 0xff, gg = g * 0xff, bb = b * 0xff; - for (i =0; i