diff --git a/src/nsimage.m b/src/nsimage.m index e76a7db..a2e0618 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -206,6 +206,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) fg: (unsigned long)fg bg: (unsigned long)bg { unsigned char *planes[5]; + unsigned char bg_alpha = 0xff; [self initWithSize: NSMakeSize (w, h)]; @@ -219,7 +220,10 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) [bmRep getBitmapDataPlanes: planes]; if (fg == 0 && bg == 0) - bg = 0xffffff; + { + bg = 0xffffff; + bg_alpha = 0; + } { /* pull bits out to set the (bytewise) alpha mask */ @@ -244,21 +248,22 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) c = *s++; for (k = 0; i < w && k < 8; ++k, ++i) { - *alpha++ = 0xff; - if (c & 1) + if (c & 0x80) { *rr++ = fgr; *gg++ = fgg; *bb++ = fgb; + *alpha++ = 0xff; } else { *rr++ = bgr; *gg++ = bgg; *bb++ = bgb; + *alpha++ = bg_alpha; } idx++; - c >>= 1; + c <<= 1; } } } diff --git a/src/nsterm.h b/src/nsterm.h index 3fb8cfc..2e3076d 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -2461,6 +2461,10 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, static EmacsImage **bimgs = NULL; static int nBimgs = 0; + // NSTRACE ("ns_draw_fringe_bitmap"); + // NSTRACE_MSG ("which:%d cursor:%d overlay:%d", + // p->which, p->cursor_p, p->overlay_p); + /* grow bimgs if needed */ if (nBimgs < max_used_fringe_bitmap) { @@ -2499,13 +2503,15 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, unsigned char *cbits = xmalloc (len); for (i = 0; i < len; i++) - cbits[i] = ~(bits[i] & 0xff); + cbits[i] = bits[i]; img = [[EmacsImage alloc] initFromXBM: cbits width: 8 height: p->h fg: 0 bg: 0]; bimgs[p->which - 1] = img; xfree (cbits); } + // NSTRACE_RECT ("r", r); + NSRectClip (r); /* Since we composite the bitmap instead of just blitting it, we need to erase the whole background. */