diff options
| author | Alan Third | 2019-12-06 16:49:25 +0000 |
|---|---|---|
| committer | Alan Third | 2019-12-10 20:38:21 +0000 |
| commit | 9546a2a0d6653a7d930cda722f5babbebb0a1d0c (patch) | |
| tree | 11b17204fb9b2e11899f3298bee2f70483586341 /src | |
| parent | 33a37360defdc08a5d8eeabffef96f8571d3b608 (diff) | |
| download | emacs-9546a2a0d6653a7d930cda722f5babbebb0a1d0c.tar.gz emacs-9546a2a0d6653a7d930cda722f5babbebb0a1d0c.zip | |
Fix XBM files on NS (bug#26133)
Reinstate some of the functionality removed in commit
67a878f78f879ce534232408c34dd11f42dd802b.
* src/nsimage.m (ns_image_from_XBM): Use new reverseBytes argument.
([EmacsImage initFromXBM:width:height:fg:bg:reverseBytes:]): Add
ability to reverse the contents of each byte for use with XBMs, while
still working with fringe bitmaps.
* src/nsterm.h
([EmacsImage initFromXBM:width:height:fg:bg:reverseBytes:]): Modified
function definition.
* src/nsterm.m (ns_draw_fringe_bitmap): Use new reverseBytes argument.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsimage.m | 17 | ||||
| -rw-r--r-- | src/nsterm.h | 3 | ||||
| -rw-r--r-- | src/nsterm.m | 3 |
3 files changed, 17 insertions, 6 deletions
diff --git a/src/nsimage.m b/src/nsimage.m index e1408c77f58..25d3b2299cb 100644 --- a/src/nsimage.m +++ b/src/nsimage.m | |||
| @@ -52,7 +52,7 @@ ns_image_from_XBM (char *bits, int width, int height, | |||
| 52 | NSTRACE ("ns_image_from_XBM"); | 52 | NSTRACE ("ns_image_from_XBM"); |
| 53 | return [[EmacsImage alloc] initFromXBM: (unsigned char *) bits | 53 | return [[EmacsImage alloc] initFromXBM: (unsigned char *) bits |
| 54 | width: width height: height | 54 | width: width height: height |
| 55 | fg: fg bg: bg]; | 55 | fg: fg bg: bg reverseBytes: YES]; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | void * | 58 | void * |
| @@ -228,7 +228,8 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) | |||
| 228 | /* Create image from monochrome bitmap. If both FG and BG are 0 | 228 | /* Create image from monochrome bitmap. If both FG and BG are 0 |
| 229 | (black), set the background to white and make it transparent. */ | 229 | (black), set the background to white and make it transparent. */ |
| 230 | - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h | 230 | - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h |
| 231 | fg: (unsigned long)fg bg: (unsigned long)bg | 231 | fg: (unsigned long)fg bg: (unsigned long)bg |
| 232 | reverseBytes: (BOOL)reverse | ||
| 232 | { | 233 | { |
| 233 | unsigned char *planes[5]; | 234 | unsigned char *planes[5]; |
| 234 | unsigned char bg_alpha = 0xff; | 235 | unsigned char bg_alpha = 0xff; |
| @@ -252,6 +253,8 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) | |||
| 252 | 253 | ||
| 253 | { | 254 | { |
| 254 | /* Pull bits out to set the (bytewise) alpha mask. */ | 255 | /* Pull bits out to set the (bytewise) alpha mask. */ |
| 256 | unsigned char swt[16] = {0, 8, 4, 12, 2, 10, 6, 14, | ||
| 257 | 1, 9, 5, 13, 3, 11, 7, 15}; | ||
| 255 | int i, j, k; | 258 | int i, j, k; |
| 256 | unsigned char *s = bits; | 259 | unsigned char *s = bits; |
| 257 | unsigned char *rr = planes[0]; | 260 | unsigned char *rr = planes[0]; |
| @@ -266,11 +269,18 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) | |||
| 266 | unsigned char bgb = bg & 0xff; | 269 | unsigned char bgb = bg & 0xff; |
| 267 | unsigned char c; | 270 | unsigned char c; |
| 268 | 271 | ||
| 269 | int idx = 0; | ||
| 270 | for (j = 0; j < h; ++j) | 272 | for (j = 0; j < h; ++j) |
| 271 | for (i = 0; i < w; ) | 273 | for (i = 0; i < w; ) |
| 272 | { | 274 | { |
| 273 | c = *s++; | 275 | c = *s++; |
| 276 | |||
| 277 | /* XBM files have the bits in reverse order within each byte | ||
| 278 | as compared to our fringe bitmaps. This function deals | ||
| 279 | with both so has to be able to handle the bytes in either | ||
| 280 | order. */ | ||
| 281 | if (reverse) | ||
| 282 | c = swt[c >> 4] | (swt[c & 0xf] << 4); | ||
| 283 | |||
| 274 | for (k = 0; i < w && k < 8; ++k, ++i) | 284 | for (k = 0; i < w && k < 8; ++k, ++i) |
| 275 | { | 285 | { |
| 276 | if (c & 0x80) | 286 | if (c & 0x80) |
| @@ -287,7 +297,6 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) | |||
| 287 | *bb++ = bgb; | 297 | *bb++ = bgb; |
| 288 | *alpha++ = bg_alpha; | 298 | *alpha++ = bg_alpha; |
| 289 | } | 299 | } |
| 290 | idx++; | ||
| 291 | c <<= 1; | 300 | c <<= 1; |
| 292 | } | 301 | } |
| 293 | } | 302 | } |
diff --git a/src/nsterm.h b/src/nsterm.h index 9773eb3e662..3803009afa6 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -639,7 +639,8 @@ typedef id instancetype; | |||
| 639 | + (instancetype)allocInitFromFile: (Lisp_Object)file; | 639 | + (instancetype)allocInitFromFile: (Lisp_Object)file; |
| 640 | - (void)dealloc; | 640 | - (void)dealloc; |
| 641 | - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h | 641 | - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h |
| 642 | fg: (unsigned long)fg bg: (unsigned long)bg; | 642 | fg: (unsigned long)fg bg: (unsigned long)bg |
| 643 | reverseBytes: (BOOL)reverse; | ||
| 643 | - (instancetype)setXBMColor: (NSColor *)color; | 644 | - (instancetype)setXBMColor: (NSColor *)color; |
| 644 | - (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: (int)height; | 645 | - (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: (int)height; |
| 645 | - (void)setPixmapData; | 646 | - (void)setPixmapData; |
diff --git a/src/nsterm.m b/src/nsterm.m index 6d8fe350e24..c4151598906 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -3106,7 +3106,8 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, | |||
| 3106 | cbits[i] = bits[i]; | 3106 | cbits[i] = bits[i]; |
| 3107 | img = [[EmacsImage alloc] initFromXBM: cbits width: 8 | 3107 | img = [[EmacsImage alloc] initFromXBM: cbits width: 8 |
| 3108 | height: full_height | 3108 | height: full_height |
| 3109 | fg: 0 bg: 0]; | 3109 | fg: 0 bg: 0 |
| 3110 | reverseBytes: NO]; | ||
| 3110 | bimgs[p->which - 1] = img; | 3111 | bimgs[p->which - 1] = img; |
| 3111 | xfree (cbits); | 3112 | xfree (cbits); |
| 3112 | } | 3113 | } |