diff options
| author | Adrian Robert | 2008-07-15 18:15:18 +0000 |
|---|---|---|
| committer | Adrian Robert | 2008-07-15 18:15:18 +0000 |
| commit | edfda78355c5528eee489fa8a7f9c73bf8e734f2 (patch) | |
| tree | 78d2414d9791e1efc17ec9b35b438ae35602340a /src/image.c | |
| parent | 1391cd548782097e34d7856ec4f20ca90bdf2c26 (diff) | |
| download | emacs-edfda78355c5528eee489fa8a7f9c73bf8e734f2.tar.gz emacs-edfda78355c5528eee489fa8a7f9c73bf8e734f2.zip | |
merging Emacs.app (NeXTstep port)
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 256 |
1 files changed, 222 insertions, 34 deletions
diff --git a/src/image.c b/src/image.c index 652c738d109..1d73704b388 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -131,6 +131,32 @@ typedef struct mac_bitmap_record Bitmap_Record; | |||
| 131 | #endif /* MAC_OS */ | 131 | #endif /* MAC_OS */ |
| 132 | 132 | ||
| 133 | 133 | ||
| 134 | #ifdef HAVE_NS | ||
| 135 | #include "nsterm.h" | ||
| 136 | #include <sys/types.h> | ||
| 137 | #include <sys/stat.h> | ||
| 138 | |||
| 139 | #undef COLOR_TABLE_SUPPORT | ||
| 140 | |||
| 141 | typedef struct ns_bitmap_record Bitmap_Record; | ||
| 142 | |||
| 143 | #define GET_PIXEL(ximg, x, y) XGetPixel(ximg, x, y) | ||
| 144 | #define NO_PIXMAP 0 | ||
| 145 | |||
| 146 | #define RGB_PIXEL_COLOR unsigned long | ||
| 147 | #define ZPixmap 0 | ||
| 148 | |||
| 149 | #define PIX_MASK_RETAIN 0 | ||
| 150 | #define PIX_MASK_DRAW 1 | ||
| 151 | |||
| 152 | #define FRAME_X_VISUAL FRAME_NS_DISPLAY_INFO(f)->visual | ||
| 153 | #define x_defined_color(f, name, color_def, alloc) \ | ||
| 154 | ns_defined_color (f, name, color_def, alloc, 0) | ||
| 155 | #define FRAME_X_SCREEN(f) 0 | ||
| 156 | #define DefaultDepthOfScreen(screen) ns_display_list->n_planes | ||
| 157 | #endif /* HAVE_NS */ | ||
| 158 | |||
| 159 | |||
| 134 | /* Search path for bitmap files. */ | 160 | /* Search path for bitmap files. */ |
| 135 | 161 | ||
| 136 | Lisp_Object Vx_bitmap_file_path; | 162 | Lisp_Object Vx_bitmap_file_path; |
| @@ -403,6 +429,33 @@ mac_create_cg_image_from_image (f, img) | |||
| 403 | #endif /* USE_CG_DRAWING */ | 429 | #endif /* USE_CG_DRAWING */ |
| 404 | #endif /* MAC_OS */ | 430 | #endif /* MAC_OS */ |
| 405 | 431 | ||
| 432 | #ifdef HAVE_NS | ||
| 433 | XImagePtr | ||
| 434 | XGetImage (Display *display, Pixmap pixmap, int x, int y, | ||
| 435 | unsigned int width, unsigned int height, | ||
| 436 | unsigned long plane_mask, int format) | ||
| 437 | { | ||
| 438 | /* PENDING: not sure what this function is supposed to do.. */ | ||
| 439 | ns_retain_object(pixmap); | ||
| 440 | return pixmap; | ||
| 441 | } | ||
| 442 | |||
| 443 | /* use with imgs created by ns_image_for_XPM */ | ||
| 444 | unsigned long | ||
| 445 | XGetPixel (XImagePtr ximage, int x, int y) | ||
| 446 | { | ||
| 447 | return ns_get_pixel(ximage, x, y); | ||
| 448 | } | ||
| 449 | |||
| 450 | /* use with imgs created by ns_image_for_XPM; alpha set to 1; | ||
| 451 | pixel is assumed to be in form RGB */ | ||
| 452 | void | ||
| 453 | XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel) | ||
| 454 | { | ||
| 455 | ns_put_pixel(ximage, x, y, pixel); | ||
| 456 | } | ||
| 457 | #endif /* HAVE_NS */ | ||
| 458 | |||
| 406 | 459 | ||
| 407 | /* Functions to access the contents of a bitmap, given an id. */ | 460 | /* Functions to access the contents of a bitmap, given an id. */ |
| 408 | 461 | ||
| @@ -519,12 +572,23 @@ x_create_bitmap_from_data (f, bits, width, height) | |||
| 519 | return -1; | 572 | return -1; |
| 520 | #endif | 573 | #endif |
| 521 | 574 | ||
| 575 | #ifdef HAVE_NS | ||
| 576 | void *bitmap = ns_image_from_XBM(bits, width, height); | ||
| 577 | if (!bitmap) | ||
| 578 | return -1; | ||
| 579 | #endif | ||
| 580 | |||
| 522 | id = x_allocate_bitmap_record (f); | 581 | id = x_allocate_bitmap_record (f); |
| 523 | #ifdef MAC_OS | 582 | #ifdef MAC_OS |
| 524 | dpyinfo->bitmaps[id - 1].bitmap_data = (char *) xmalloc (height * width); | 583 | dpyinfo->bitmaps[id - 1].bitmap_data = (char *) xmalloc (height * width); |
| 525 | bcopy (bits, dpyinfo->bitmaps[id - 1].bitmap_data, height * width); | 584 | bcopy (bits, dpyinfo->bitmaps[id - 1].bitmap_data, height * width); |
| 526 | #endif /* MAC_OS */ | 585 | #endif /* MAC_OS */ |
| 527 | 586 | ||
| 587 | #ifdef HAVE_NS | ||
| 588 | dpyinfo->bitmaps[id - 1].img = bitmap; | ||
| 589 | dpyinfo->bitmaps[id - 1].depth = 1; | ||
| 590 | #endif | ||
| 591 | |||
| 528 | dpyinfo->bitmaps[id - 1].file = NULL; | 592 | dpyinfo->bitmaps[id - 1].file = NULL; |
| 529 | dpyinfo->bitmaps[id - 1].height = height; | 593 | dpyinfo->bitmaps[id - 1].height = height; |
| 530 | dpyinfo->bitmaps[id - 1].width = width; | 594 | dpyinfo->bitmaps[id - 1].width = width; |
| @@ -552,6 +616,8 @@ x_create_bitmap_from_file (f, file) | |||
| 552 | struct frame *f; | 616 | struct frame *f; |
| 553 | Lisp_Object file; | 617 | Lisp_Object file; |
| 554 | { | 618 | { |
| 619 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | ||
| 620 | |||
| 555 | #ifdef MAC_OS | 621 | #ifdef MAC_OS |
| 556 | return -1; /* MAC_TODO : bitmap support */ | 622 | return -1; /* MAC_TODO : bitmap support */ |
| 557 | #endif /* MAC_OS */ | 623 | #endif /* MAC_OS */ |
| @@ -560,8 +626,26 @@ x_create_bitmap_from_file (f, file) | |||
| 560 | return -1; /* W32_TODO : bitmap support */ | 626 | return -1; /* W32_TODO : bitmap support */ |
| 561 | #endif /* HAVE_NTGUI */ | 627 | #endif /* HAVE_NTGUI */ |
| 562 | 628 | ||
| 629 | #ifdef HAVE_NS | ||
| 630 | int id; | ||
| 631 | void *bitmap = ns_image_from_file(file); | ||
| 632 | |||
| 633 | if (!bitmap) | ||
| 634 | return -1; | ||
| 635 | |||
| 636 | |||
| 637 | id = x_allocate_bitmap_record (f); | ||
| 638 | dpyinfo->bitmaps[id - 1].img = bitmap; | ||
| 639 | dpyinfo->bitmaps[id - 1].refcount = 1; | ||
| 640 | dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1); | ||
| 641 | dpyinfo->bitmaps[id - 1].depth = 1; | ||
| 642 | dpyinfo->bitmaps[id - 1].height = ns_image_width(bitmap); | ||
| 643 | dpyinfo->bitmaps[id - 1].width = ns_image_height(bitmap); | ||
| 644 | strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file)); | ||
| 645 | return id; | ||
| 646 | #endif | ||
| 647 | |||
| 563 | #ifdef HAVE_X_WINDOWS | 648 | #ifdef HAVE_X_WINDOWS |
| 564 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | ||
| 565 | unsigned int width, height; | 649 | unsigned int width, height; |
| 566 | Pixmap bitmap; | 650 | Pixmap bitmap; |
| 567 | int xhot, yhot, result, id; | 651 | int xhot, yhot, result, id; |
| @@ -630,6 +714,10 @@ free_bitmap_record (dpyinfo, bm) | |||
| 630 | bm->bitmap_data = NULL; | 714 | bm->bitmap_data = NULL; |
| 631 | #endif /* MAC_OS */ | 715 | #endif /* MAC_OS */ |
| 632 | 716 | ||
| 717 | #ifdef HAVE_NS | ||
| 718 | ns_release_object(bm->img); | ||
| 719 | #endif | ||
| 720 | |||
| 633 | if (bm->file) | 721 | if (bm->file) |
| 634 | { | 722 | { |
| 635 | xfree (bm->file); | 723 | xfree (bm->file); |
| @@ -1407,7 +1495,8 @@ image_ascent (img, face, slice) | |||
| 1407 | because a typical font is `top-heavy' (due to the presence | 1495 | because a typical font is `top-heavy' (due to the presence |
| 1408 | uppercase letters), so the image placement should err towards | 1496 | uppercase letters), so the image placement should err towards |
| 1409 | being top-heavy too. It also just generally looks better. */ | 1497 | being top-heavy too. It also just generally looks better. */ |
| 1410 | ascent = (height + face->font->ascent - face->font->descent + 1) / 2; | 1498 | ascent = (height + FONT_BASE(face->font) |
| 1499 | - FONT_DESCENT(face->font) + 1) / 2; | ||
| 1411 | #endif /* HAVE_NTGUI */ | 1500 | #endif /* HAVE_NTGUI */ |
| 1412 | } | 1501 | } |
| 1413 | else | 1502 | else |
| @@ -1476,6 +1565,14 @@ four_corners_best (ximg, corners, width, height) | |||
| 1476 | #define Free_Pixmap(display, pixmap) \ | 1565 | #define Free_Pixmap(display, pixmap) \ |
| 1477 | DeleteObject (pixmap) | 1566 | DeleteObject (pixmap) |
| 1478 | 1567 | ||
| 1568 | #elif defined (HAVE_NS) | ||
| 1569 | |||
| 1570 | #define Destroy_Image(ximg, dummy) \ | ||
| 1571 | ns_release_object(ximg) | ||
| 1572 | |||
| 1573 | #define Free_Pixmap(display, pixmap) \ | ||
| 1574 | ns_release_object(pixmap) | ||
| 1575 | |||
| 1479 | #else | 1576 | #else |
| 1480 | 1577 | ||
| 1481 | #define Destroy_Image(ximg, dummy) \ | 1578 | #define Destroy_Image(ximg, dummy) \ |
| @@ -1484,7 +1581,7 @@ four_corners_best (ximg, corners, width, height) | |||
| 1484 | #define Free_Pixmap(display, pixmap) \ | 1581 | #define Free_Pixmap(display, pixmap) \ |
| 1485 | XFreePixmap (display, pixmap) | 1582 | XFreePixmap (display, pixmap) |
| 1486 | 1583 | ||
| 1487 | #endif /* HAVE_NTGUI */ | 1584 | #endif /* !HAVE_NTGUI && !HAVE_NS */ |
| 1488 | 1585 | ||
| 1489 | 1586 | ||
| 1490 | /* Return the `background' field of IMG. If IMG doesn't have one yet, | 1587 | /* Return the `background' field of IMG. If IMG doesn't have one yet, |
| @@ -1607,6 +1704,10 @@ x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p) | |||
| 1607 | { | 1704 | { |
| 1608 | Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap); | 1705 | Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap); |
| 1609 | img->pixmap = NO_PIXMAP; | 1706 | img->pixmap = NO_PIXMAP; |
| 1707 | #ifdef HAVE_NS | ||
| 1708 | if (img->background_valid) | ||
| 1709 | ns_free_indexed_color(img->background); | ||
| 1710 | #endif | ||
| 1610 | img->background_valid = 0; | 1711 | img->background_valid = 0; |
| 1611 | } | 1712 | } |
| 1612 | 1713 | ||
| @@ -2387,6 +2488,18 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) | |||
| 2387 | return 1; | 2488 | return 1; |
| 2388 | 2489 | ||
| 2389 | #endif /* MAC_OS */ | 2490 | #endif /* MAC_OS */ |
| 2491 | |||
| 2492 | #ifdef HAVE_NS | ||
| 2493 | *pixmap = ns_image_for_XPM(width, height, depth); | ||
| 2494 | if (*pixmap == 0) | ||
| 2495 | { | ||
| 2496 | *ximg = NULL; | ||
| 2497 | image_error ("Unable to allocate NSImage for XPM pixmap", Qnil, Qnil); | ||
| 2498 | return 0; | ||
| 2499 | } | ||
| 2500 | *ximg = *pixmap; | ||
| 2501 | return 1; | ||
| 2502 | #endif | ||
| 2390 | } | 2503 | } |
| 2391 | 2504 | ||
| 2392 | 2505 | ||
| @@ -2412,6 +2525,9 @@ x_destroy_x_image (ximg) | |||
| 2412 | #ifdef MAC_OS | 2525 | #ifdef MAC_OS |
| 2413 | XDestroyImage (ximg); | 2526 | XDestroyImage (ximg); |
| 2414 | #endif /* MAC_OS */ | 2527 | #endif /* MAC_OS */ |
| 2528 | #ifdef HAVE_NS | ||
| 2529 | ns_release_object(ximg); | ||
| 2530 | #endif /* HAVE_NS */ | ||
| 2415 | } | 2531 | } |
| 2416 | } | 2532 | } |
| 2417 | 2533 | ||
| @@ -2446,6 +2562,11 @@ x_put_x_image (f, ximg, pixmap, width, height) | |||
| 2446 | #ifdef MAC_OS | 2562 | #ifdef MAC_OS |
| 2447 | xassert (ximg == pixmap); | 2563 | xassert (ximg == pixmap); |
| 2448 | #endif /* MAC_OS */ | 2564 | #endif /* MAC_OS */ |
| 2565 | |||
| 2566 | #ifdef HAVE_NS | ||
| 2567 | xassert (ximg == pixmap); | ||
| 2568 | ns_retain_object(ximg); | ||
| 2569 | #endif | ||
| 2449 | } | 2570 | } |
| 2450 | 2571 | ||
| 2451 | 2572 | ||
| @@ -3499,6 +3620,10 @@ Create_Pixmap_From_Bitmap_Data (f, img, data, fg, bg, non_default_colors) | |||
| 3499 | /* If colors were specified, transfer the bitmap to a color one. */ | 3620 | /* If colors were specified, transfer the bitmap to a color one. */ |
| 3500 | if (non_default_colors) | 3621 | if (non_default_colors) |
| 3501 | convert_mono_to_color_image (f, img, fg, bg); | 3622 | convert_mono_to_color_image (f, img, fg, bg); |
| 3623 | |||
| 3624 | #elif defined (HAVE_NS) | ||
| 3625 | img->pixmap = ns_image_from_XBM(data, img->width, img->height); | ||
| 3626 | |||
| 3502 | #else | 3627 | #else |
| 3503 | img->pixmap | 3628 | img->pixmap |
| 3504 | = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f), | 3629 | = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f), |
| @@ -3507,7 +3632,7 @@ Create_Pixmap_From_Bitmap_Data (f, img, data, fg, bg, non_default_colors) | |||
| 3507 | img->width, img->height, | 3632 | img->width, img->height, |
| 3508 | fg, bg, | 3633 | fg, bg, |
| 3509 | DefaultDepthOfScreen (FRAME_X_SCREEN (f))); | 3634 | DefaultDepthOfScreen (FRAME_X_SCREEN (f))); |
| 3510 | #endif /* HAVE_NTGUI */ | 3635 | #endif /* !HAVE_NTGUI && !HAVE_NS */ |
| 3511 | } | 3636 | } |
| 3512 | 3637 | ||
| 3513 | 3638 | ||
| @@ -3891,13 +4016,13 @@ xbm_load (f, img) | |||
| 3891 | XPM images | 4016 | XPM images |
| 3892 | ***********************************************************************/ | 4017 | ***********************************************************************/ |
| 3893 | 4018 | ||
| 3894 | #if defined (HAVE_XPM) || defined (MAC_OS) | 4019 | #if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS) |
| 3895 | 4020 | ||
| 3896 | static int xpm_image_p P_ ((Lisp_Object object)); | 4021 | static int xpm_image_p P_ ((Lisp_Object object)); |
| 3897 | static int xpm_load P_ ((struct frame *f, struct image *img)); | 4022 | static int xpm_load P_ ((struct frame *f, struct image *img)); |
| 3898 | static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); | 4023 | static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); |
| 3899 | 4024 | ||
| 3900 | #endif /* HAVE_XPM || MAC_OS */ | 4025 | #endif /* HAVE_XPM || MAC_OS || HAVE_NS */ |
| 3901 | 4026 | ||
| 3902 | #ifdef HAVE_XPM | 4027 | #ifdef HAVE_XPM |
| 3903 | #ifdef HAVE_NTGUI | 4028 | #ifdef HAVE_NTGUI |
| @@ -3920,7 +4045,7 @@ static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); | |||
| 3920 | #endif /* HAVE_NTGUI */ | 4045 | #endif /* HAVE_NTGUI */ |
| 3921 | #endif /* HAVE_XPM */ | 4046 | #endif /* HAVE_XPM */ |
| 3922 | 4047 | ||
| 3923 | #if defined (HAVE_XPM) || defined (MAC_OS) | 4048 | #if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS) |
| 3924 | /* The symbol `xpm' identifying XPM-format images. */ | 4049 | /* The symbol `xpm' identifying XPM-format images. */ |
| 3925 | 4050 | ||
| 3926 | Lisp_Object Qxpm; | 4051 | Lisp_Object Qxpm; |
| @@ -4247,7 +4372,7 @@ xpm_image_p (object) | |||
| 4247 | || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value))); | 4372 | || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value))); |
| 4248 | } | 4373 | } |
| 4249 | 4374 | ||
| 4250 | #endif /* HAVE_XPM || MAC_OS */ | 4375 | #endif /* HAVE_XPM || MAC_OS || HAVE_NS */ |
| 4251 | 4376 | ||
| 4252 | #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) | 4377 | #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) |
| 4253 | int | 4378 | int |
| @@ -4526,7 +4651,7 @@ xpm_load (f, img) | |||
| 4526 | 4651 | ||
| 4527 | #endif /* HAVE_XPM */ | 4652 | #endif /* HAVE_XPM */ |
| 4528 | 4653 | ||
| 4529 | #ifdef MAC_OS | 4654 | #if defined (MAC_OS) || ( defined (HAVE_NS) && !defined (HAVE_XPM) ) |
| 4530 | 4655 | ||
| 4531 | /* XPM support functions for Mac OS where libxpm is not available. | 4656 | /* XPM support functions for Mac OS where libxpm is not available. |
| 4532 | Only XPM version 3 (without any extensions) is supported. */ | 4657 | Only XPM version 3 (without any extensions) is supported. */ |
| @@ -4884,8 +5009,11 @@ xpm_load_image (f, img, contents, end) | |||
| 4884 | 5009 | ||
| 4885 | if (!x_create_x_image_and_pixmap (f, width, height, 0, | 5010 | if (!x_create_x_image_and_pixmap (f, width, height, 0, |
| 4886 | &ximg, &img->pixmap) | 5011 | &ximg, &img->pixmap) |
| 5012 | #ifndef HAVE_NS | ||
| 4887 | || !x_create_x_image_and_pixmap (f, width, height, 1, | 5013 | || !x_create_x_image_and_pixmap (f, width, height, 1, |
| 4888 | &mask_img, &img->mask)) | 5014 | &mask_img, &img->mask) |
| 5015 | #endif | ||
| 5016 | ) | ||
| 4889 | { | 5017 | { |
| 4890 | image_error ("Out of memory (%s)", img->spec, Qnil); | 5018 | image_error ("Out of memory (%s)", img->spec, Qnil); |
| 4891 | goto error; | 5019 | goto error; |
| @@ -4905,9 +5033,14 @@ xpm_load_image (f, img, contents, end) | |||
| 4905 | XPutPixel (ximg, x, y, | 5033 | XPutPixel (ximg, x, y, |
| 4906 | (INTEGERP (color_val) ? XINT (color_val) | 5034 | (INTEGERP (color_val) ? XINT (color_val) |
| 4907 | : FRAME_FOREGROUND_PIXEL (f))); | 5035 | : FRAME_FOREGROUND_PIXEL (f))); |
| 5036 | #ifndef HAVE_NS | ||
| 4908 | XPutPixel (mask_img, x, y, | 5037 | XPutPixel (mask_img, x, y, |
| 4909 | (!EQ (color_val, Qt) ? PIX_MASK_DRAW | 5038 | (!EQ (color_val, Qt) ? PIX_MASK_DRAW |
| 4910 | : (have_mask = 1, PIX_MASK_RETAIN))); | 5039 | : (have_mask = 1, PIX_MASK_RETAIN))); |
| 5040 | #else | ||
| 5041 | if (EQ(color_val, Qt)) | ||
| 5042 | ns_set_alpha(ximg, x, y, 0); | ||
| 5043 | #endif | ||
| 4911 | } | 5044 | } |
| 4912 | if (y + 1 < height) | 5045 | if (y + 1 < height) |
| 4913 | expect (','); | 5046 | expect (','); |
| @@ -4922,6 +5055,7 @@ xpm_load_image (f, img, contents, end) | |||
| 4922 | 5055 | ||
| 4923 | x_put_x_image (f, ximg, img->pixmap, width, height); | 5056 | x_put_x_image (f, ximg, img->pixmap, width, height); |
| 4924 | x_destroy_x_image (ximg); | 5057 | x_destroy_x_image (ximg); |
| 5058 | #ifndef HAVE_NS | ||
| 4925 | if (have_mask) | 5059 | if (have_mask) |
| 4926 | { | 5060 | { |
| 4927 | /* Fill in the background_transparent field while we have the | 5061 | /* Fill in the background_transparent field while we have the |
| @@ -4937,7 +5071,7 @@ xpm_load_image (f, img, contents, end) | |||
| 4937 | Free_Pixmap (FRAME_X_DISPLAY (f), img->mask); | 5071 | Free_Pixmap (FRAME_X_DISPLAY (f), img->mask); |
| 4938 | img->mask = NO_PIXMAP; | 5072 | img->mask = NO_PIXMAP; |
| 4939 | } | 5073 | } |
| 4940 | 5074 | #endif | |
| 4941 | return 1; | 5075 | return 1; |
| 4942 | 5076 | ||
| 4943 | failure: | 5077 | failure: |
| @@ -5003,7 +5137,7 @@ xpm_load (f, img) | |||
| 5003 | return success_p; | 5137 | return success_p; |
| 5004 | } | 5138 | } |
| 5005 | 5139 | ||
| 5006 | #endif /* MAC_OS */ | 5140 | #endif /* MAC_OS || (HAVE_NS && !HAVE_XPM) */ |
| 5007 | 5141 | ||
| 5008 | 5142 | ||
| 5009 | 5143 | ||
| @@ -5273,6 +5407,9 @@ lookup_rgb_color (f, r, g, b) | |||
| 5273 | pixel = PALETTERGB (r >> 8, g >> 8, b >> 8); | 5407 | pixel = PALETTERGB (r >> 8, g >> 8, b >> 8); |
| 5274 | #endif /* HAVE_NTGUI */ | 5408 | #endif /* HAVE_NTGUI */ |
| 5275 | 5409 | ||
| 5410 | #ifdef HAVE_NS | ||
| 5411 | pixel = RGB_TO_ULONG (r >> 8, g >> 8, b >> 8); | ||
| 5412 | #endif /* HAVE_NS */ | ||
| 5276 | return pixel; | 5413 | return pixel; |
| 5277 | } | 5414 | } |
| 5278 | 5415 | ||
| @@ -5378,7 +5515,7 @@ x_to_xcolors (f, img, rgb_p) | |||
| 5378 | p->pixel = GET_PIXEL (ximg, x, y); | 5515 | p->pixel = GET_PIXEL (ximg, x, y); |
| 5379 | if (rgb_p) | 5516 | if (rgb_p) |
| 5380 | { | 5517 | { |
| 5381 | #ifdef MAC_OS | 5518 | #if defined (MAC_OS) || defined (HAVE_NS) |
| 5382 | p->red = RED16_FROM_ULONG (p->pixel); | 5519 | p->red = RED16_FROM_ULONG (p->pixel); |
| 5383 | p->green = GREEN16_FROM_ULONG (p->pixel); | 5520 | p->green = GREEN16_FROM_ULONG (p->pixel); |
| 5384 | p->blue = BLUE16_FROM_ULONG (p->pixel); | 5521 | p->blue = BLUE16_FROM_ULONG (p->pixel); |
| @@ -5459,8 +5596,8 @@ x_from_xcolors (f, img, colors) | |||
| 5459 | XColor *colors; | 5596 | XColor *colors; |
| 5460 | { | 5597 | { |
| 5461 | int x, y; | 5598 | int x, y; |
| 5462 | XImagePtr oimg; | 5599 | XImagePtr oimg = NULL; |
| 5463 | Pixmap pixmap; | 5600 | Pixmap pixmap = NULL; |
| 5464 | XColor *p; | 5601 | XColor *p; |
| 5465 | 5602 | ||
| 5466 | init_color_table (); | 5603 | init_color_table (); |
| @@ -5673,6 +5810,8 @@ x_disable_image (f, img) | |||
| 5673 | Display *dpy = FRAME_X_DISPLAY (f); | 5810 | Display *dpy = FRAME_X_DISPLAY (f); |
| 5674 | GC gc; | 5811 | GC gc; |
| 5675 | 5812 | ||
| 5813 | #ifndef HAVE_NS //TODO: NS support, however this not needed for toolbars | ||
| 5814 | |||
| 5676 | #ifdef MAC_OS | 5815 | #ifdef MAC_OS |
| 5677 | #define MaskForeground(f) PIX_MASK_DRAW | 5816 | #define MaskForeground(f) PIX_MASK_DRAW |
| 5678 | #else | 5817 | #else |
| @@ -5697,6 +5836,7 @@ x_disable_image (f, img) | |||
| 5697 | img->width - 1, 0); | 5836 | img->width - 1, 0); |
| 5698 | XFreeGC (dpy, gc); | 5837 | XFreeGC (dpy, gc); |
| 5699 | } | 5838 | } |
| 5839 | #endif /* !HAVE_NS */ | ||
| 5700 | #else | 5840 | #else |
| 5701 | HDC hdc, bmpdc; | 5841 | HDC hdc, bmpdc; |
| 5702 | HGDIOBJ prev; | 5842 | HGDIOBJ prev; |
| @@ -5762,11 +5902,13 @@ x_build_heuristic_mask (f, img, how) | |||
| 5762 | } | 5902 | } |
| 5763 | 5903 | ||
| 5764 | #ifndef HAVE_NTGUI | 5904 | #ifndef HAVE_NTGUI |
| 5905 | #ifndef HAVE_NS | ||
| 5765 | /* Create an image and pixmap serving as mask. */ | 5906 | /* Create an image and pixmap serving as mask. */ |
| 5766 | rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1, | 5907 | rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1, |
| 5767 | &mask_img, &img->mask); | 5908 | &mask_img, &img->mask); |
| 5768 | if (!rc) | 5909 | if (!rc) |
| 5769 | return 0; | 5910 | return 0; |
| 5911 | #endif /* !HAVE_NS */ | ||
| 5770 | 5912 | ||
| 5771 | /* Get the X image of IMG->pixmap. */ | 5913 | /* Get the X image of IMG->pixmap. */ |
| 5772 | ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap, 0, 0, | 5914 | ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap, 0, 0, |
| @@ -5820,16 +5962,21 @@ x_build_heuristic_mask (f, img, how) | |||
| 5820 | #ifndef HAVE_NTGUI | 5962 | #ifndef HAVE_NTGUI |
| 5821 | for (y = 0; y < img->height; ++y) | 5963 | for (y = 0; y < img->height; ++y) |
| 5822 | for (x = 0; x < img->width; ++x) | 5964 | for (x = 0; x < img->width; ++x) |
| 5965 | #ifndef HAVE_NS | ||
| 5823 | XPutPixel (mask_img, x, y, (XGetPixel (ximg, x, y) != bg | 5966 | XPutPixel (mask_img, x, y, (XGetPixel (ximg, x, y) != bg |
| 5824 | ? PIX_MASK_DRAW : PIX_MASK_RETAIN)); | 5967 | ? PIX_MASK_DRAW : PIX_MASK_RETAIN)); |
| 5825 | 5968 | #else | |
| 5969 | if (XGetPixel (ximg, x, y) == bg) | ||
| 5970 | ns_set_alpha(ximg, x, y, 0); | ||
| 5971 | #endif /* HAVE_NS */ | ||
| 5972 | #ifndef HAVE_NS | ||
| 5826 | /* Fill in the background_transparent field while we have the mask handy. */ | 5973 | /* Fill in the background_transparent field while we have the mask handy. */ |
| 5827 | image_background_transparent (img, f, mask_img); | 5974 | image_background_transparent (img, f, mask_img); |
| 5828 | 5975 | ||
| 5829 | /* Put mask_img into img->mask. */ | 5976 | /* Put mask_img into img->mask. */ |
| 5830 | x_put_x_image (f, mask_img, img->mask, img->width, img->height); | 5977 | x_put_x_image (f, mask_img, img->mask, img->width, img->height); |
| 5831 | x_destroy_x_image (mask_img); | 5978 | x_destroy_x_image (mask_img); |
| 5832 | 5979 | #endif /* !HAVE_NS */ | |
| 5833 | #else | 5980 | #else |
| 5834 | for (y = 0; y < img->height; ++y) | 5981 | for (y = 0; y < img->height; ++y) |
| 5835 | for (x = 0; x < img->width; ++x) | 5982 | for (x = 0; x < img->width; ++x) |
| @@ -6280,7 +6427,7 @@ pbm_load (f, img) | |||
| 6280 | PNG | 6427 | PNG |
| 6281 | ***********************************************************************/ | 6428 | ***********************************************************************/ |
| 6282 | 6429 | ||
| 6283 | #if defined (HAVE_PNG) || defined (MAC_OS) | 6430 | #if defined (HAVE_PNG) || defined (MAC_OS) || defined (HAVE_NS) |
| 6284 | 6431 | ||
| 6285 | /* Function prototypes. */ | 6432 | /* Function prototypes. */ |
| 6286 | 6433 | ||
| @@ -6352,7 +6499,7 @@ png_image_p (object) | |||
| 6352 | return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1; | 6499 | return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1; |
| 6353 | } | 6500 | } |
| 6354 | 6501 | ||
| 6355 | #endif /* HAVE_PNG || MAC_OS */ | 6502 | #endif /* HAVE_PNG || MAC_OS || HAVE_NS */ |
| 6356 | 6503 | ||
| 6357 | 6504 | ||
| 6358 | #ifdef HAVE_PNG | 6505 | #ifdef HAVE_PNG |
| @@ -6912,6 +7059,17 @@ png_load (f, img) | |||
| 6912 | } | 7059 | } |
| 6913 | #endif /* MAC_OS */ | 7060 | #endif /* MAC_OS */ |
| 6914 | 7061 | ||
| 7062 | #ifdef HAVE_NS | ||
| 7063 | static int | ||
| 7064 | png_load (struct frame *f, struct image *img) | ||
| 7065 | { | ||
| 7066 | return ns_load_image(f, img, | ||
| 7067 | image_spec_value (img->spec, QCfile, NULL), | ||
| 7068 | image_spec_value (img->spec, QCdata, NULL)); | ||
| 7069 | } | ||
| 7070 | #endif /* HAVE_NS */ | ||
| 7071 | |||
| 7072 | |||
| 6915 | #endif /* !HAVE_PNG */ | 7073 | #endif /* !HAVE_PNG */ |
| 6916 | 7074 | ||
| 6917 | 7075 | ||
| @@ -6920,7 +7078,7 @@ png_load (f, img) | |||
| 6920 | JPEG | 7078 | JPEG |
| 6921 | ***********************************************************************/ | 7079 | ***********************************************************************/ |
| 6922 | 7080 | ||
| 6923 | #if defined (HAVE_JPEG) || defined (MAC_OS) | 7081 | #if defined (HAVE_JPEG) || defined (MAC_OS) || defined (HAVE_NS) |
| 6924 | 7082 | ||
| 6925 | static int jpeg_image_p P_ ((Lisp_Object object)); | 7083 | static int jpeg_image_p P_ ((Lisp_Object object)); |
| 6926 | static int jpeg_load P_ ((struct frame *f, struct image *img)); | 7084 | static int jpeg_load P_ ((struct frame *f, struct image *img)); |
| @@ -6991,7 +7149,7 @@ jpeg_image_p (object) | |||
| 6991 | return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1; | 7149 | return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1; |
| 6992 | } | 7150 | } |
| 6993 | 7151 | ||
| 6994 | #endif /* HAVE_JPEG || MAC_OS */ | 7152 | #endif /* HAVE_JPEG || MAC_OS || HAVE_NS */ |
| 6995 | 7153 | ||
| 6996 | #ifdef HAVE_JPEG | 7154 | #ifdef HAVE_JPEG |
| 6997 | 7155 | ||
| @@ -7491,6 +7649,16 @@ jpeg_load (f, img) | |||
| 7491 | } | 7649 | } |
| 7492 | #endif /* MAC_OS */ | 7650 | #endif /* MAC_OS */ |
| 7493 | 7651 | ||
| 7652 | #ifdef HAVE_NS | ||
| 7653 | static int | ||
| 7654 | jpeg_load (struct frame *f, struct image *img) | ||
| 7655 | { | ||
| 7656 | return ns_load_image(f, img, | ||
| 7657 | image_spec_value (img->spec, QCfile, NULL), | ||
| 7658 | image_spec_value (img->spec, QCdata, NULL)); | ||
| 7659 | } | ||
| 7660 | #endif /* HAVE_NS */ | ||
| 7661 | |||
| 7494 | #endif /* !HAVE_JPEG */ | 7662 | #endif /* !HAVE_JPEG */ |
| 7495 | 7663 | ||
| 7496 | 7664 | ||
| @@ -7499,7 +7667,7 @@ jpeg_load (f, img) | |||
| 7499 | TIFF | 7667 | TIFF |
| 7500 | ***********************************************************************/ | 7668 | ***********************************************************************/ |
| 7501 | 7669 | ||
| 7502 | #if defined (HAVE_TIFF) || defined (MAC_OS) | 7670 | #if defined (HAVE_TIFF) || defined (MAC_OS) || defined (HAVE_NS) |
| 7503 | 7671 | ||
| 7504 | static int tiff_image_p P_ ((Lisp_Object object)); | 7672 | static int tiff_image_p P_ ((Lisp_Object object)); |
| 7505 | static int tiff_load P_ ((struct frame *f, struct image *img)); | 7673 | static int tiff_load P_ ((struct frame *f, struct image *img)); |
| @@ -7569,7 +7737,7 @@ tiff_image_p (object) | |||
| 7569 | return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1; | 7737 | return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1; |
| 7570 | } | 7738 | } |
| 7571 | 7739 | ||
| 7572 | #endif /* HAVE_TIFF || MAC_OS */ | 7740 | #endif /* HAVE_TIFF || MAC_OS || HAVE_NS */ |
| 7573 | 7741 | ||
| 7574 | #ifdef HAVE_TIFF | 7742 | #ifdef HAVE_TIFF |
| 7575 | 7743 | ||
| @@ -7916,6 +8084,16 @@ tiff_load (f, img) | |||
| 7916 | } | 8084 | } |
| 7917 | #endif /* MAC_OS */ | 8085 | #endif /* MAC_OS */ |
| 7918 | 8086 | ||
| 8087 | #ifdef HAVE_NS | ||
| 8088 | static int | ||
| 8089 | tiff_load (struct frame *f, struct image *img) | ||
| 8090 | { | ||
| 8091 | return ns_load_image(f, img, | ||
| 8092 | image_spec_value (img->spec, QCfile, NULL), | ||
| 8093 | image_spec_value (img->spec, QCdata, NULL)); | ||
| 8094 | } | ||
| 8095 | #endif /* HAVE_NS */ | ||
| 8096 | |||
| 7919 | #endif /* !HAVE_TIFF */ | 8097 | #endif /* !HAVE_TIFF */ |
| 7920 | 8098 | ||
| 7921 | 8099 | ||
| @@ -7924,7 +8102,7 @@ tiff_load (f, img) | |||
| 7924 | GIF | 8102 | GIF |
| 7925 | ***********************************************************************/ | 8103 | ***********************************************************************/ |
| 7926 | 8104 | ||
| 7927 | #if defined (HAVE_GIF) || defined (MAC_OS) | 8105 | #if defined (HAVE_GIF) || defined (MAC_OS) || defined (HAVE_NS) |
| 7928 | 8106 | ||
| 7929 | static int gif_image_p P_ ((Lisp_Object object)); | 8107 | static int gif_image_p P_ ((Lisp_Object object)); |
| 7930 | static int gif_load P_ ((struct frame *f, struct image *img)); | 8108 | static int gif_load P_ ((struct frame *f, struct image *img)); |
| @@ -8553,6 +8731,16 @@ gif_load (f, img) | |||
| 8553 | } | 8731 | } |
| 8554 | #endif /* MAC_OS */ | 8732 | #endif /* MAC_OS */ |
| 8555 | 8733 | ||
| 8734 | #ifdef HAVE_NS | ||
| 8735 | static int | ||
| 8736 | gif_load (struct frame *f, struct image *img) | ||
| 8737 | { | ||
| 8738 | return ns_load_image(f, img, | ||
| 8739 | image_spec_value (img->spec, QCfile, NULL), | ||
| 8740 | image_spec_value (img->spec, QCdata, NULL)); | ||
| 8741 | } | ||
| 8742 | #endif /* HAVE_NS */ | ||
| 8743 | |||
| 8556 | #endif /* HAVE_GIF */ | 8744 | #endif /* HAVE_GIF */ |
| 8557 | 8745 | ||
| 8558 | 8746 | ||
| @@ -9335,27 +9523,27 @@ of `image-library-alist', which see). */) | |||
| 9335 | if (CONSP (tested)) | 9523 | if (CONSP (tested)) |
| 9336 | return XCDR (tested); | 9524 | return XCDR (tested); |
| 9337 | 9525 | ||
| 9338 | #if defined (HAVE_XPM) || defined (MAC_OS) | 9526 | #if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS) |
| 9339 | if (EQ (type, Qxpm)) | 9527 | if (EQ (type, Qxpm)) |
| 9340 | return CHECK_LIB_AVAILABLE (&xpm_type, init_xpm_functions, libraries); | 9528 | return CHECK_LIB_AVAILABLE (&xpm_type, init_xpm_functions, libraries); |
| 9341 | #endif | 9529 | #endif |
| 9342 | 9530 | ||
| 9343 | #if defined (HAVE_JPEG) || defined (MAC_OS) | 9531 | #if defined (HAVE_JPEG) || defined (MAC_OS) || defined (HAVE_NS) |
| 9344 | if (EQ (type, Qjpeg)) | 9532 | if (EQ (type, Qjpeg)) |
| 9345 | return CHECK_LIB_AVAILABLE (&jpeg_type, init_jpeg_functions, libraries); | 9533 | return CHECK_LIB_AVAILABLE (&jpeg_type, init_jpeg_functions, libraries); |
| 9346 | #endif | 9534 | #endif |
| 9347 | 9535 | ||
| 9348 | #if defined (HAVE_TIFF) || defined (MAC_OS) | 9536 | #if defined (HAVE_TIFF) || defined (MAC_OS) || defined (HAVE_NS) |
| 9349 | if (EQ (type, Qtiff)) | 9537 | if (EQ (type, Qtiff)) |
| 9350 | return CHECK_LIB_AVAILABLE (&tiff_type, init_tiff_functions, libraries); | 9538 | return CHECK_LIB_AVAILABLE (&tiff_type, init_tiff_functions, libraries); |
| 9351 | #endif | 9539 | #endif |
| 9352 | 9540 | ||
| 9353 | #if defined (HAVE_GIF) || defined (MAC_OS) | 9541 | #if defined (HAVE_GIF) || defined (MAC_OS) || defined (HAVE_NS) |
| 9354 | if (EQ (type, Qgif)) | 9542 | if (EQ (type, Qgif)) |
| 9355 | return CHECK_LIB_AVAILABLE (&gif_type, init_gif_functions, libraries); | 9543 | return CHECK_LIB_AVAILABLE (&gif_type, init_gif_functions, libraries); |
| 9356 | #endif | 9544 | #endif |
| 9357 | 9545 | ||
| 9358 | #if defined (HAVE_PNG) || defined (MAC_OS) | 9546 | #if defined (HAVE_PNG) || defined (MAC_OS) || defined (HAVE_NS) |
| 9359 | if (EQ (type, Qpng)) | 9547 | if (EQ (type, Qpng)) |
| 9360 | return CHECK_LIB_AVAILABLE (&png_type, init_png_functions, libraries); | 9548 | return CHECK_LIB_AVAILABLE (&png_type, init_png_functions, libraries); |
| 9361 | #endif | 9549 | #endif |
| @@ -9480,31 +9668,31 @@ non-numeric, there is no explicit limit on the size of images. */); | |||
| 9480 | staticpro (&QCpt_height); | 9668 | staticpro (&QCpt_height); |
| 9481 | #endif /* HAVE_GHOSTSCRIPT */ | 9669 | #endif /* HAVE_GHOSTSCRIPT */ |
| 9482 | 9670 | ||
| 9483 | #if defined (HAVE_XPM) || defined (MAC_OS) | 9671 | #if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS) |
| 9484 | Qxpm = intern ("xpm"); | 9672 | Qxpm = intern ("xpm"); |
| 9485 | staticpro (&Qxpm); | 9673 | staticpro (&Qxpm); |
| 9486 | ADD_IMAGE_TYPE (Qxpm); | 9674 | ADD_IMAGE_TYPE (Qxpm); |
| 9487 | #endif | 9675 | #endif |
| 9488 | 9676 | ||
| 9489 | #if defined (HAVE_JPEG) || defined (MAC_OS) | 9677 | #if defined (HAVE_JPEG) || defined (MAC_OS) || defined (HAVE_NS) |
| 9490 | Qjpeg = intern ("jpeg"); | 9678 | Qjpeg = intern ("jpeg"); |
| 9491 | staticpro (&Qjpeg); | 9679 | staticpro (&Qjpeg); |
| 9492 | ADD_IMAGE_TYPE (Qjpeg); | 9680 | ADD_IMAGE_TYPE (Qjpeg); |
| 9493 | #endif | 9681 | #endif |
| 9494 | 9682 | ||
| 9495 | #if defined (HAVE_TIFF) || defined (MAC_OS) | 9683 | #if defined (HAVE_TIFF) || defined (MAC_OS) || defined (HAVE_NS) |
| 9496 | Qtiff = intern ("tiff"); | 9684 | Qtiff = intern ("tiff"); |
| 9497 | staticpro (&Qtiff); | 9685 | staticpro (&Qtiff); |
| 9498 | ADD_IMAGE_TYPE (Qtiff); | 9686 | ADD_IMAGE_TYPE (Qtiff); |
| 9499 | #endif | 9687 | #endif |
| 9500 | 9688 | ||
| 9501 | #if defined (HAVE_GIF) || defined (MAC_OS) | 9689 | #if defined (HAVE_GIF) || defined (MAC_OS) || defined (HAVE_NS) |
| 9502 | Qgif = intern ("gif"); | 9690 | Qgif = intern ("gif"); |
| 9503 | staticpro (&Qgif); | 9691 | staticpro (&Qgif); |
| 9504 | ADD_IMAGE_TYPE (Qgif); | 9692 | ADD_IMAGE_TYPE (Qgif); |
| 9505 | #endif | 9693 | #endif |
| 9506 | 9694 | ||
| 9507 | #if defined (HAVE_PNG) || defined (MAC_OS) | 9695 | #if defined (HAVE_PNG) || defined (MAC_OS) || defined (HAVE_NS) |
| 9508 | Qpng = intern ("png"); | 9696 | Qpng = intern ("png"); |
| 9509 | staticpro (&Qpng); | 9697 | staticpro (&Qpng); |
| 9510 | ADD_IMAGE_TYPE (Qpng); | 9698 | ADD_IMAGE_TYPE (Qpng); |