diff options
| author | Dan Nicolaescu | 2008-07-27 18:24:48 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-07-27 18:24:48 +0000 |
| commit | 9e2a2647758db83b490e2993aa31cd4607305a82 (patch) | |
| tree | 9c3d41b47bcd316c60d56bef8d7fd32789e59411 /src/image.c | |
| parent | 7f19297073b2dd6c28987bf5663933591f59e91e (diff) | |
| download | emacs-9e2a2647758db83b490e2993aa31cd4607305a82.tar.gz emacs-9e2a2647758db83b490e2993aa31cd4607305a82.zip | |
Remove support for Mac Carbon.
* mactoolbox.c:
* macterm.h:
* macterm.c:
* macselect.c:
* macmenu.c:
* macgui.h:
* macfns.c:
* mac.c: Remove file.
* s/darwin.h:
* m/intel386.h:
* xfaces.c:
* xdisp.c:
* window.c:
* tparam.c:
* termhooks.h:
* termcap.c:
* term.c:
* syssignal.h:
* sysselect.h:
* sysdep.c:
* process.c:
* lread.c:
* lisp.h:
* keyboard.c:
* image.c:
* fringe.c:
* frame.h:
* frame.c:
* fontset.c:
* font.h:
* font.c:
* fns.c:
* fileio.c:
* emacs.c:
* dispnew.c:
* dispextern.h:
* config.in:
* atimer.c:
* Makefile.in: Remove code for Carbon
* erc.el: Remove code for Carbon.
Remove support for Mac Carbon.
* term/mac-win.el: Remove file
* international/mule-cmds.el:
* version.el:
* startup.el:
* simple.el:
* mwheel.el:
* mouse.el:
* loadup.el:
* isearch.el:
* info.el:
* frame.el:
* faces.el:
* disp-table.el:
* cus-start.el:
* cus-face.el:
* cus-edit.el:
* Makefile.in: Remove code for Carbon.
Remove support for Mac Carbon.
* makefile.w32-in:
* emacsclient.c: Remove code for Carbon.
* PROBLEMS:
* MACHINES: Remove mentions of Mac Carbon.
* ns-emacs.texi:
* faq.texi: Remove mentions of Mac Carbon.
* os.texi:
* frames.texi:
* display.texi: Remove mentions of Mac Carbon.
* xresources.texi: Remove mentions of Mac Carbon.
* make-tarball.txt:
* admin.el:
* FOR-RELEASE:
* CPP-DEFINES: Remove mentions of Mac Carbon.
Remove support for Mac Carbon.
* mac: Remove directory.
* make-dist:
* configure.in:
* README:
* Makefile.in:
* INSTALL: Remove code for Carbon.
* configure: Regenerate.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 1053 |
1 files changed, 32 insertions, 1021 deletions
diff --git a/src/image.c b/src/image.c index 7aee1e6512e..1312d132f5c 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -81,56 +81,6 @@ typedef struct w32_bitmap_record Bitmap_Record; | |||
| 81 | #define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits) | 81 | #define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits) |
| 82 | #endif /* HAVE_NTGUI */ | 82 | #endif /* HAVE_NTGUI */ |
| 83 | 83 | ||
| 84 | |||
| 85 | #ifdef MAC_OS | ||
| 86 | #include "macterm.h" | ||
| 87 | #include <sys/stat.h> | ||
| 88 | #ifndef MAC_OSX | ||
| 89 | #include <alloca.h> | ||
| 90 | #include <sys/param.h> | ||
| 91 | #endif | ||
| 92 | #if TARGET_API_MAC_CARBON | ||
| 93 | #ifdef MAC_OSX | ||
| 94 | #include <QuickTime/QuickTime.h> | ||
| 95 | #else /* not MAC_OSX */ | ||
| 96 | #include <QuickTime.h> | ||
| 97 | #endif /* not MAC_OSX */ | ||
| 98 | #else /* not TARGET_API_MAC_CARBON */ | ||
| 99 | #include <Windows.h> | ||
| 100 | #include <Gestalt.h> | ||
| 101 | #include <TextUtils.h> | ||
| 102 | #include <ImageCompression.h> | ||
| 103 | #include <QuickTimeComponents.h> | ||
| 104 | #endif /* not TARGET_API_MAC_CARBON */ | ||
| 105 | |||
| 106 | /* MAC_TODO : Color tables on Mac. */ | ||
| 107 | #undef COLOR_TABLE_SUPPORT | ||
| 108 | |||
| 109 | #define ZPixmap 0 /* arbitrary */ | ||
| 110 | typedef struct mac_bitmap_record Bitmap_Record; | ||
| 111 | |||
| 112 | #define GET_PIXEL(ximg, x, y) XGetPixel(ximg, x, y) | ||
| 113 | #define NO_PIXMAP 0 | ||
| 114 | |||
| 115 | #define RGB_PIXEL_COLOR unsigned long | ||
| 116 | |||
| 117 | #if USE_MAC_IMAGE_IO | ||
| 118 | #define PIX_MASK_DRAW 255 | ||
| 119 | #define PIX_MASK_RETAIN 0 | ||
| 120 | #else | ||
| 121 | /* A black pixel in a mask bitmap/pixmap means ``draw a source | ||
| 122 | pixel''. A white pixel means ``retain the current pixel''. */ | ||
| 123 | #define PIX_MASK_DRAW RGB_TO_ULONG(0,0,0) | ||
| 124 | #define PIX_MASK_RETAIN RGB_TO_ULONG(255,255,255) | ||
| 125 | #endif | ||
| 126 | |||
| 127 | #define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual | ||
| 128 | #define x_defined_color mac_defined_color | ||
| 129 | #define DefaultDepthOfScreen(screen) (one_mac_display_info.n_planes) | ||
| 130 | |||
| 131 | #endif /* MAC_OS */ | ||
| 132 | |||
| 133 | |||
| 134 | #ifdef HAVE_NS | 84 | #ifdef HAVE_NS |
| 135 | #include "nsterm.h" | 85 | #include "nsterm.h" |
| 136 | #include <sys/types.h> | 86 | #include <sys/types.h> |
| @@ -564,12 +514,6 @@ x_create_bitmap_from_data (f, bits, width, height) | |||
| 564 | return -1; | 514 | return -1; |
| 565 | #endif /* HAVE_NTGUI */ | 515 | #endif /* HAVE_NTGUI */ |
| 566 | 516 | ||
| 567 | #ifdef MAC_OS | ||
| 568 | /* MAC_TODO: for now fail if width is not mod 16 (toolbox requires it) */ | ||
| 569 | if (width % 16 != 0) | ||
| 570 | return -1; | ||
| 571 | #endif | ||
| 572 | |||
| 573 | #ifdef HAVE_NS | 517 | #ifdef HAVE_NS |
| 574 | void *bitmap = ns_image_from_XBM(bits, width, height); | 518 | void *bitmap = ns_image_from_XBM(bits, width, height); |
| 575 | if (!bitmap) | 519 | if (!bitmap) |
| @@ -577,10 +521,6 @@ x_create_bitmap_from_data (f, bits, width, height) | |||
| 577 | #endif | 521 | #endif |
| 578 | 522 | ||
| 579 | id = x_allocate_bitmap_record (f); | 523 | id = x_allocate_bitmap_record (f); |
| 580 | #ifdef MAC_OS | ||
| 581 | dpyinfo->bitmaps[id - 1].bitmap_data = (char *) xmalloc (height * width); | ||
| 582 | bcopy (bits, dpyinfo->bitmaps[id - 1].bitmap_data, height * width); | ||
| 583 | #endif /* MAC_OS */ | ||
| 584 | 524 | ||
| 585 | #ifdef HAVE_NS | 525 | #ifdef HAVE_NS |
| 586 | dpyinfo->bitmaps[id - 1].img = bitmap; | 526 | dpyinfo->bitmaps[id - 1].img = bitmap; |
| @@ -616,10 +556,6 @@ x_create_bitmap_from_file (f, file) | |||
| 616 | { | 556 | { |
| 617 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 557 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 618 | 558 | ||
| 619 | #ifdef MAC_OS | ||
| 620 | return -1; /* MAC_TODO : bitmap support */ | ||
| 621 | #endif /* MAC_OS */ | ||
| 622 | |||
| 623 | #ifdef HAVE_NTGUI | 559 | #ifdef HAVE_NTGUI |
| 624 | return -1; /* W32_TODO : bitmap support */ | 560 | return -1; /* W32_TODO : bitmap support */ |
| 625 | #endif /* HAVE_NTGUI */ | 561 | #endif /* HAVE_NTGUI */ |
| @@ -707,11 +643,6 @@ free_bitmap_record (dpyinfo, bm) | |||
| 707 | DeleteObject (bm->pixmap); | 643 | DeleteObject (bm->pixmap); |
| 708 | #endif /* HAVE_NTGUI */ | 644 | #endif /* HAVE_NTGUI */ |
| 709 | 645 | ||
| 710 | #ifdef MAC_OS | ||
| 711 | xfree (bm->bitmap_data); /* Added ++kfs */ | ||
| 712 | bm->bitmap_data = NULL; | ||
| 713 | #endif /* MAC_OS */ | ||
| 714 | |||
| 715 | #ifdef HAVE_NS | 646 | #ifdef HAVE_NS |
| 716 | ns_release_object(bm->img); | 647 | ns_release_object(bm->img); |
| 717 | #endif | 648 | #endif |
| @@ -1446,17 +1377,6 @@ prepare_image_for_display (f, img) | |||
| 1446 | if (img->pixmap == NO_PIXMAP && !img->load_failed_p) | 1377 | if (img->pixmap == NO_PIXMAP && !img->load_failed_p) |
| 1447 | img->load_failed_p = img->type->load (f, img) == 0; | 1378 | img->load_failed_p = img->type->load (f, img) == 0; |
| 1448 | 1379 | ||
| 1449 | #if defined (MAC_OS) && USE_CG_DRAWING | ||
| 1450 | if (!img->load_failed_p && img->data.ptr_val == NULL) | ||
| 1451 | { | ||
| 1452 | img->data.ptr_val = mac_create_cg_image_from_image (f, img); | ||
| 1453 | if (img->data.ptr_val == NULL) | ||
| 1454 | { | ||
| 1455 | img->load_failed_p = 1; | ||
| 1456 | img->type->free (f, img); | ||
| 1457 | } | ||
| 1458 | } | ||
| 1459 | #endif | ||
| 1460 | } | 1380 | } |
| 1461 | 1381 | ||
| 1462 | 1382 | ||
| @@ -1718,7 +1638,6 @@ x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p) | |||
| 1718 | 1638 | ||
| 1719 | if (colors_p && img->ncolors) | 1639 | if (colors_p && img->ncolors) |
| 1720 | { | 1640 | { |
| 1721 | /* MAC_TODO: color table support. */ | ||
| 1722 | /* W32_TODO: color table support. */ | 1641 | /* W32_TODO: color table support. */ |
| 1723 | #ifdef HAVE_X_WINDOWS | 1642 | #ifdef HAVE_X_WINDOWS |
| 1724 | x_free_colors (f, img->colors, img->ncolors); | 1643 | x_free_colors (f, img->colors, img->ncolors); |
| @@ -1728,13 +1647,6 @@ x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p) | |||
| 1728 | img->ncolors = 0; | 1647 | img->ncolors = 0; |
| 1729 | } | 1648 | } |
| 1730 | 1649 | ||
| 1731 | #if defined (MAC_OS) && USE_CG_DRAWING | ||
| 1732 | if (img->data.ptr_val) | ||
| 1733 | { | ||
| 1734 | CGImageRelease (img->data.ptr_val); | ||
| 1735 | img->data.ptr_val = NULL; | ||
| 1736 | } | ||
| 1737 | #endif | ||
| 1738 | } | 1650 | } |
| 1739 | 1651 | ||
| 1740 | /* Free X resources of image IMG which is used on frame F. */ | 1652 | /* Free X resources of image IMG which is used on frame F. */ |
| @@ -2279,7 +2191,7 @@ mark_image_cache (struct image_cache *c) | |||
| 2279 | 2191 | ||
| 2280 | 2192 | ||
| 2281 | /*********************************************************************** | 2193 | /*********************************************************************** |
| 2282 | X / MAC / W32 support code | 2194 | X / NS / W32 support code |
| 2283 | ***********************************************************************/ | 2195 | ***********************************************************************/ |
| 2284 | 2196 | ||
| 2285 | #ifdef HAVE_NTGUI | 2197 | #ifdef HAVE_NTGUI |
| @@ -2464,29 +2376,6 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) | |||
| 2464 | 2376 | ||
| 2465 | #endif /* HAVE_NTGUI */ | 2377 | #endif /* HAVE_NTGUI */ |
| 2466 | 2378 | ||
| 2467 | #ifdef MAC_OS | ||
| 2468 | Display *display = FRAME_X_DISPLAY (f); | ||
| 2469 | Window window = FRAME_X_WINDOW (f); | ||
| 2470 | |||
| 2471 | xassert (interrupt_input_blocked); | ||
| 2472 | |||
| 2473 | /* Allocate a pixmap of the same size. */ | ||
| 2474 | *pixmap = XCreatePixmap (display, window, width, height, depth); | ||
| 2475 | if (*pixmap == NO_PIXMAP) | ||
| 2476 | { | ||
| 2477 | *ximg = NULL; | ||
| 2478 | image_error ("Unable to create X pixmap", Qnil, Qnil); | ||
| 2479 | return 0; | ||
| 2480 | } | ||
| 2481 | |||
| 2482 | #if !USE_MAC_IMAGE_IO | ||
| 2483 | LockPixels (GetGWorldPixMap (*pixmap)); | ||
| 2484 | #endif | ||
| 2485 | *ximg = *pixmap; | ||
| 2486 | return 1; | ||
| 2487 | |||
| 2488 | #endif /* MAC_OS */ | ||
| 2489 | |||
| 2490 | #ifdef HAVE_NS | 2379 | #ifdef HAVE_NS |
| 2491 | *pixmap = ns_image_for_XPM(width, height, depth); | 2380 | *pixmap = ns_image_for_XPM(width, height, depth); |
| 2492 | if (*pixmap == 0) | 2381 | if (*pixmap == 0) |
| @@ -2520,9 +2409,6 @@ x_destroy_x_image (ximg) | |||
| 2520 | ximg->data = NULL; | 2409 | ximg->data = NULL; |
| 2521 | xfree (ximg); | 2410 | xfree (ximg); |
| 2522 | #endif /* HAVE_NTGUI */ | 2411 | #endif /* HAVE_NTGUI */ |
| 2523 | #ifdef MAC_OS | ||
| 2524 | XDestroyImage (ximg); | ||
| 2525 | #endif /* MAC_OS */ | ||
| 2526 | #ifdef HAVE_NS | 2412 | #ifdef HAVE_NS |
| 2527 | ns_release_object(ximg); | 2413 | ns_release_object(ximg); |
| 2528 | #endif /* HAVE_NS */ | 2414 | #endif /* HAVE_NS */ |
| @@ -2557,10 +2443,6 @@ x_put_x_image (f, ximg, pixmap, width, height) | |||
| 2557 | #endif | 2443 | #endif |
| 2558 | #endif /* HAVE_NTGUI */ | 2444 | #endif /* HAVE_NTGUI */ |
| 2559 | 2445 | ||
| 2560 | #ifdef MAC_OS | ||
| 2561 | xassert (ximg == pixmap); | ||
| 2562 | #endif /* MAC_OS */ | ||
| 2563 | |||
| 2564 | #ifdef HAVE_NS | 2446 | #ifdef HAVE_NS |
| 2565 | xassert (ximg == pixmap); | 2447 | xassert (ximg == pixmap); |
| 2566 | ns_retain_object(ximg); | 2448 | ns_retain_object(ximg); |
| @@ -2648,593 +2530,6 @@ slurp_file (file, size) | |||
| 2648 | 2530 | ||
| 2649 | 2531 | ||
| 2650 | 2532 | ||
| 2651 | #ifdef MAC_OS | ||
| 2652 | |||
| 2653 | /*********************************************************************** | ||
| 2654 | MAC Image Load Functions | ||
| 2655 | ***********************************************************************/ | ||
| 2656 | |||
| 2657 | #if USE_MAC_IMAGE_IO | ||
| 2658 | static int | ||
| 2659 | image_load_image_io (f, img, type) | ||
| 2660 | struct frame *f; | ||
| 2661 | struct image *img; | ||
| 2662 | CFStringRef type; | ||
| 2663 | { | ||
| 2664 | CFDictionaryRef options, src_props = NULL, props = NULL; | ||
| 2665 | CFStringRef keys[2]; | ||
| 2666 | CFTypeRef values[2]; | ||
| 2667 | Lisp_Object specified_file, specified_data; | ||
| 2668 | CGImageSourceRef source = NULL; | ||
| 2669 | size_t count; | ||
| 2670 | CGImageRef image = NULL; | ||
| 2671 | int loop_count = -1; | ||
| 2672 | double delay_time = -1.0; | ||
| 2673 | int width, height; | ||
| 2674 | XImagePtr ximg = NULL; | ||
| 2675 | CGContextRef context; | ||
| 2676 | CGRect rectangle; | ||
| 2677 | int has_alpha_p, gif_p; | ||
| 2678 | |||
| 2679 | gif_p = UTTypeEqual (type, kUTTypeGIF); | ||
| 2680 | |||
| 2681 | keys[0] = kCGImageSourceTypeIdentifierHint; | ||
| 2682 | values[0] = (CFTypeRef) type; | ||
| 2683 | keys[1] = kCGImageSourceShouldCache; | ||
| 2684 | values[1] = (CFTypeRef) kCFBooleanFalse; | ||
| 2685 | options = CFDictionaryCreate (NULL, (const void **) keys, | ||
| 2686 | (const void **) values, | ||
| 2687 | sizeof (keys) / sizeof (keys[0]), | ||
| 2688 | &kCFTypeDictionaryKeyCallBacks, | ||
| 2689 | &kCFTypeDictionaryValueCallBacks); | ||
| 2690 | if (options == NULL) | ||
| 2691 | { | ||
| 2692 | image_error ("Error creating options for image `%s'", img->spec, Qnil); | ||
| 2693 | return 0; | ||
| 2694 | } | ||
| 2695 | |||
| 2696 | /* Open the file. */ | ||
| 2697 | specified_file = image_spec_value (img->spec, QCfile, NULL); | ||
| 2698 | specified_data = image_spec_value (img->spec, QCdata, NULL); | ||
| 2699 | |||
| 2700 | if (NILP (specified_data)) | ||
| 2701 | { | ||
| 2702 | Lisp_Object file; | ||
| 2703 | CFStringRef path; | ||
| 2704 | CFURLRef url; | ||
| 2705 | |||
| 2706 | file = x_find_image_file (specified_file); | ||
| 2707 | if (!STRINGP (file)) | ||
| 2708 | { | ||
| 2709 | image_error ("Cannot find image file `%s'", specified_file, Qnil); | ||
| 2710 | return 0; | ||
| 2711 | } | ||
| 2712 | path = cfstring_create_with_utf8_cstring (SDATA (file)); | ||
| 2713 | if (path) | ||
| 2714 | { | ||
| 2715 | url = CFURLCreateWithFileSystemPath (NULL, path, | ||
| 2716 | kCFURLPOSIXPathStyle, 0); | ||
| 2717 | CFRelease (path); | ||
| 2718 | if (url) | ||
| 2719 | { | ||
| 2720 | source = CGImageSourceCreateWithURL (url, NULL); | ||
| 2721 | CFRelease (url); | ||
| 2722 | } | ||
| 2723 | } | ||
| 2724 | } | ||
| 2725 | else | ||
| 2726 | { | ||
| 2727 | CFDataRef data = CFDataCreate (NULL, SDATA (specified_data), | ||
| 2728 | SBYTES (specified_data)); | ||
| 2729 | |||
| 2730 | if (data) | ||
| 2731 | { | ||
| 2732 | source = CGImageSourceCreateWithData (data, options); | ||
| 2733 | CFRelease (data); | ||
| 2734 | } | ||
| 2735 | } | ||
| 2736 | CFRelease (options); | ||
| 2737 | |||
| 2738 | if (source) | ||
| 2739 | { | ||
| 2740 | CFStringRef real_type = CGImageSourceGetType (source); | ||
| 2741 | |||
| 2742 | if (real_type && UTTypeEqual (type, real_type)) | ||
| 2743 | src_props = CGImageSourceCopyProperties (source, NULL); | ||
| 2744 | if (src_props) | ||
| 2745 | { | ||
| 2746 | EMACS_INT ino = 0; | ||
| 2747 | |||
| 2748 | count = CGImageSourceGetCount (source); | ||
| 2749 | if (gif_p) | ||
| 2750 | { | ||
| 2751 | Lisp_Object image = image_spec_value (img->spec, QCindex, NULL); | ||
| 2752 | |||
| 2753 | if (INTEGERP (image)) | ||
| 2754 | ino = XFASTINT (image); | ||
| 2755 | } | ||
| 2756 | if (ino >= 0 && ino < count) | ||
| 2757 | { | ||
| 2758 | props = CGImageSourceCopyPropertiesAtIndex (source, ino, NULL); | ||
| 2759 | if (props) | ||
| 2760 | image = CGImageSourceCreateImageAtIndex (source, ino, NULL); | ||
| 2761 | } | ||
| 2762 | } | ||
| 2763 | CFRelease (source); | ||
| 2764 | } | ||
| 2765 | |||
| 2766 | if (image == NULL) | ||
| 2767 | { | ||
| 2768 | if (src_props) | ||
| 2769 | CFRelease (src_props); | ||
| 2770 | if (props) | ||
| 2771 | CFRelease (props); | ||
| 2772 | image_error ("Error reading image `%s'", img->spec, Qnil); | ||
| 2773 | return 0; | ||
| 2774 | } | ||
| 2775 | else | ||
| 2776 | { | ||
| 2777 | CFBooleanRef boolean; | ||
| 2778 | |||
| 2779 | if (CFDictionaryGetValueIfPresent (props, kCGImagePropertyHasAlpha, | ||
| 2780 | (const void **) &boolean)) | ||
| 2781 | has_alpha_p = CFBooleanGetValue (boolean); | ||
| 2782 | if (gif_p) | ||
| 2783 | { | ||
| 2784 | CFDictionaryRef dict; | ||
| 2785 | CFNumberRef number; | ||
| 2786 | |||
| 2787 | dict = CFDictionaryGetValue (src_props, | ||
| 2788 | kCGImagePropertyGIFDictionary); | ||
| 2789 | if (dict | ||
| 2790 | && CFDictionaryGetValueIfPresent (dict, | ||
| 2791 | kCGImagePropertyGIFLoopCount, | ||
| 2792 | (const void **) &number)) | ||
| 2793 | CFNumberGetValue (number, kCFNumberIntType, &loop_count); | ||
| 2794 | |||
| 2795 | dict = CFDictionaryGetValue (props, kCGImagePropertyGIFDictionary); | ||
| 2796 | if (dict | ||
| 2797 | && CFDictionaryGetValueIfPresent (dict, | ||
| 2798 | kCGImagePropertyGIFDelayTime, | ||
| 2799 | (const void **) &number)) | ||
| 2800 | CFNumberGetValue (number, kCFNumberDoubleType, &delay_time); | ||
| 2801 | } | ||
| 2802 | CFRelease (src_props); | ||
| 2803 | CFRelease (props); | ||
| 2804 | } | ||
| 2805 | |||
| 2806 | width = img->width = CGImageGetWidth (image); | ||
| 2807 | height = img->height = CGImageGetHeight (image); | ||
| 2808 | |||
| 2809 | if (!check_image_size (f, width, height)) | ||
| 2810 | { | ||
| 2811 | CGImageRelease (image); | ||
| 2812 | image_error ("Invalid image size", Qnil, Qnil); | ||
| 2813 | return 0; | ||
| 2814 | } | ||
| 2815 | |||
| 2816 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) | ||
| 2817 | { | ||
| 2818 | CGImageRelease (image); | ||
| 2819 | image_error ("Out of memory (%s)", img->spec, Qnil); | ||
| 2820 | return 0; | ||
| 2821 | } | ||
| 2822 | rectangle = CGRectMake (0, 0, width, height); | ||
| 2823 | |||
| 2824 | context = CGBitmapContextCreate (ximg->data, ximg->width, ximg->height, 8, | ||
| 2825 | ximg->bytes_per_line, | ||
| 2826 | mac_cg_color_space_rgb, | ||
| 2827 | kCGImageAlphaNoneSkipFirst | ||
| 2828 | | kCGBitmapByteOrder32Host); | ||
| 2829 | if (has_alpha_p) | ||
| 2830 | { | ||
| 2831 | Lisp_Object specified_bg; | ||
| 2832 | XColor color; | ||
| 2833 | |||
| 2834 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | ||
| 2835 | if (!STRINGP (specified_bg) | ||
| 2836 | || !mac_defined_color (f, SDATA (specified_bg), &color, 0)) | ||
| 2837 | { | ||
| 2838 | color.pixel = FRAME_BACKGROUND_PIXEL (f); | ||
| 2839 | color.red = RED16_FROM_ULONG (color.pixel); | ||
| 2840 | color.green = GREEN16_FROM_ULONG (color.pixel); | ||
| 2841 | color.blue = BLUE16_FROM_ULONG (color.pixel); | ||
| 2842 | } | ||
| 2843 | CGContextSetRGBFillColor (context, color.red / 65535.0, | ||
| 2844 | color.green / 65535.0, | ||
| 2845 | color.blue / 65535.0, 1.0); | ||
| 2846 | CGContextFillRect (context, rectangle); | ||
| 2847 | } | ||
| 2848 | CGContextDrawImage (context, rectangle, image); | ||
| 2849 | CGContextRelease (context); | ||
| 2850 | CGImageRelease (image); | ||
| 2851 | |||
| 2852 | /* Save GIF image extension data for `image-extension-data'. | ||
| 2853 | Format is (count IMAGES | ||
| 2854 | 0xff "NETSCAPE2.0" 0x00 DATA_SUB_BLOCK_FOR_LOOP_COUNT | ||
| 2855 | 0xf9 GRAPHIC_CONTROL_EXTENSION_BLOCK). */ | ||
| 2856 | if (gif_p) | ||
| 2857 | { | ||
| 2858 | img->data.lisp_val = Qnil; | ||
| 2859 | if (delay_time >= 0) | ||
| 2860 | { | ||
| 2861 | Lisp_Object gce = make_uninit_string (4); | ||
| 2862 | int centisec = delay_time * 100.0 + 0.5; | ||
| 2863 | |||
| 2864 | /* Fill the delay time field. */ | ||
| 2865 | SSET (gce, 1, centisec & 0xff); | ||
| 2866 | SSET (gce, 2, (centisec >> 8) & 0xff); | ||
| 2867 | /* We don't know about other fields. */ | ||
| 2868 | SSET (gce, 0, 0); | ||
| 2869 | SSET (gce, 3, 0); | ||
| 2870 | img->data.lisp_val = Fcons (make_number (0xf9), | ||
| 2871 | Fcons (gce, | ||
| 2872 | img->data.lisp_val)); | ||
| 2873 | } | ||
| 2874 | if (loop_count >= 0) | ||
| 2875 | { | ||
| 2876 | Lisp_Object data_sub_block = make_uninit_string (3); | ||
| 2877 | |||
| 2878 | SSET (data_sub_block, 0, 0x01); | ||
| 2879 | SSET (data_sub_block, 1, loop_count & 0xff); | ||
| 2880 | SSET (data_sub_block, 2, (loop_count >> 8) & 0xff); | ||
| 2881 | img->data.lisp_val = Fcons (make_number (0), | ||
| 2882 | Fcons (data_sub_block, | ||
| 2883 | img->data.lisp_val)); | ||
| 2884 | img->data.lisp_val = Fcons (make_number (0xff), | ||
| 2885 | Fcons (build_string ("NETSCAPE2.0"), | ||
| 2886 | img->data.lisp_val)); | ||
| 2887 | } | ||
| 2888 | if (count > 1) | ||
| 2889 | img->data.lisp_val = Fcons (Qcount, | ||
| 2890 | Fcons (make_number (count), | ||
| 2891 | img->data.lisp_val)); | ||
| 2892 | } | ||
| 2893 | |||
| 2894 | /* Maybe fill in the background field while we have ximg handy. */ | ||
| 2895 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | ||
| 2896 | IMAGE_BACKGROUND (img, f, ximg); | ||
| 2897 | |||
| 2898 | /* Put the image into the pixmap. */ | ||
| 2899 | x_put_x_image (f, ximg, img->pixmap, width, height); | ||
| 2900 | x_destroy_x_image (ximg); | ||
| 2901 | return 1; | ||
| 2902 | } | ||
| 2903 | #else /* !USE_MAC_IMAGE_IO */ | ||
| 2904 | static int image_load_quicktime P_ ((struct frame *, struct image *img, | ||
| 2905 | OSType)); | ||
| 2906 | #ifdef MAC_OSX | ||
| 2907 | static int image_load_quartz2d P_ ((struct frame *, struct image *img, int)); | ||
| 2908 | #endif | ||
| 2909 | |||
| 2910 | static OSErr | ||
| 2911 | find_image_fsspec (specified_file, file, fss) | ||
| 2912 | Lisp_Object specified_file, *file; | ||
| 2913 | FSSpec *fss; | ||
| 2914 | { | ||
| 2915 | OSErr err; | ||
| 2916 | AEDesc desc; | ||
| 2917 | |||
| 2918 | *file = x_find_image_file (specified_file); | ||
| 2919 | if (!STRINGP (*file)) | ||
| 2920 | return fnfErr; /* file or directory not found; | ||
| 2921 | incomplete pathname */ | ||
| 2922 | /* Try to open the image file. */ | ||
| 2923 | err = AECoercePtr (TYPE_FILE_NAME, SDATA (*file), | ||
| 2924 | SBYTES (*file), typeFSS, &desc); | ||
| 2925 | if (err == noErr) | ||
| 2926 | { | ||
| 2927 | #if TARGET_API_MAC_CARBON | ||
| 2928 | err = AEGetDescData (&desc, fss, sizeof (FSSpec)); | ||
| 2929 | #else | ||
| 2930 | *fss = *(FSSpec *)(*(desc.dataHandle)); | ||
| 2931 | #endif | ||
| 2932 | AEDisposeDesc (&desc); | ||
| 2933 | } | ||
| 2934 | return err; | ||
| 2935 | } | ||
| 2936 | |||
| 2937 | static int | ||
| 2938 | image_load_qt_1 (f, img, type, fss, dh) | ||
| 2939 | struct frame *f; | ||
| 2940 | struct image *img; | ||
| 2941 | OSType type; | ||
| 2942 | const FSSpec *fss; | ||
| 2943 | Handle dh; | ||
| 2944 | { | ||
| 2945 | ComponentResult err; | ||
| 2946 | GraphicsImportComponent gi; | ||
| 2947 | Rect rect; | ||
| 2948 | int width, height; | ||
| 2949 | ImageDescriptionHandle desc_handle; | ||
| 2950 | short draw_all_pixels; | ||
| 2951 | Lisp_Object specified_bg; | ||
| 2952 | XColor color; | ||
| 2953 | XImagePtr ximg; | ||
| 2954 | RGBColor bg_color; | ||
| 2955 | |||
| 2956 | err = OpenADefaultComponent (GraphicsImporterComponentType, type, &gi); | ||
| 2957 | if (err != noErr) | ||
| 2958 | { | ||
| 2959 | image_error ("Cannot get importer component for `%s'", img->spec, Qnil); | ||
| 2960 | return 0; | ||
| 2961 | } | ||
| 2962 | if (dh == NULL) | ||
| 2963 | { | ||
| 2964 | /* read from file system spec */ | ||
| 2965 | err = GraphicsImportSetDataFile (gi, fss); | ||
| 2966 | if (err != noErr) | ||
| 2967 | { | ||
| 2968 | image_error ("Cannot set fsspec to graphics importer for '%s'", | ||
| 2969 | img->spec, Qnil); | ||
| 2970 | goto error; | ||
| 2971 | } | ||
| 2972 | } | ||
| 2973 | else | ||
| 2974 | { | ||
| 2975 | /* read from data handle */ | ||
| 2976 | err = GraphicsImportSetDataHandle (gi, dh); | ||
| 2977 | if (err != noErr) | ||
| 2978 | { | ||
| 2979 | image_error ("Cannot set data handle to graphics importer for `%s'", | ||
| 2980 | img->spec, Qnil); | ||
| 2981 | goto error; | ||
| 2982 | } | ||
| 2983 | } | ||
| 2984 | err = GraphicsImportGetImageDescription (gi, &desc_handle); | ||
| 2985 | if (err != noErr || desc_handle == NULL) | ||
| 2986 | { | ||
| 2987 | image_error ("Error reading `%s'", img->spec, Qnil); | ||
| 2988 | goto error; | ||
| 2989 | } | ||
| 2990 | width = img->width = (*desc_handle)->width; | ||
| 2991 | height = img->height = (*desc_handle)->height; | ||
| 2992 | DisposeHandle ((Handle)desc_handle); | ||
| 2993 | |||
| 2994 | if (!check_image_size (f, width, height)) | ||
| 2995 | { | ||
| 2996 | image_error ("Invalid image size", Qnil, Qnil); | ||
| 2997 | goto error; | ||
| 2998 | } | ||
| 2999 | |||
| 3000 | err = GraphicsImportDoesDrawAllPixels (gi, &draw_all_pixels); | ||
| 3001 | #if 0 | ||
| 3002 | /* Don't check the error code here. It may have an undocumented | ||
| 3003 | value -32766. */ | ||
| 3004 | if (err != noErr) | ||
| 3005 | { | ||
| 3006 | image_error ("Error reading `%s'", img->spec, Qnil); | ||
| 3007 | goto error; | ||
| 3008 | } | ||
| 3009 | #endif | ||
| 3010 | if (draw_all_pixels != graphicsImporterDrawsAllPixels) | ||
| 3011 | { | ||
| 3012 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | ||
| 3013 | if (!STRINGP (specified_bg) || | ||
| 3014 | !mac_defined_color (f, SDATA (specified_bg), &color, 0)) | ||
| 3015 | { | ||
| 3016 | color.pixel = FRAME_BACKGROUND_PIXEL (f); | ||
| 3017 | color.red = RED16_FROM_ULONG (color.pixel); | ||
| 3018 | color.green = GREEN16_FROM_ULONG (color.pixel); | ||
| 3019 | color.blue = BLUE16_FROM_ULONG (color.pixel); | ||
| 3020 | } | ||
| 3021 | } | ||
| 3022 | |||
| 3023 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) | ||
| 3024 | goto error; | ||
| 3025 | if (draw_all_pixels != graphicsImporterDrawsAllPixels) | ||
| 3026 | { | ||
| 3027 | CGrafPtr old_port; | ||
| 3028 | GDHandle old_gdh; | ||
| 3029 | |||
| 3030 | GetGWorld (&old_port, &old_gdh); | ||
| 3031 | SetGWorld (ximg, NULL); | ||
| 3032 | bg_color.red = color.red; | ||
| 3033 | bg_color.green = color.green; | ||
| 3034 | bg_color.blue = color.blue; | ||
| 3035 | RGBBackColor (&bg_color); | ||
| 3036 | #if TARGET_API_MAC_CARBON | ||
| 3037 | GetPortBounds (ximg, &rect); | ||
| 3038 | EraseRect (&rect); | ||
| 3039 | #else | ||
| 3040 | EraseRect (&(ximg->portRect)); | ||
| 3041 | #endif | ||
| 3042 | SetGWorld (old_port, old_gdh); | ||
| 3043 | } | ||
| 3044 | GraphicsImportSetGWorld (gi, ximg, NULL); | ||
| 3045 | GraphicsImportDraw (gi); | ||
| 3046 | CloseComponent (gi); | ||
| 3047 | |||
| 3048 | /* Maybe fill in the background field while we have ximg handy. */ | ||
| 3049 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | ||
| 3050 | IMAGE_BACKGROUND (img, f, ximg); | ||
| 3051 | |||
| 3052 | /* Put the image into the pixmap. */ | ||
| 3053 | x_put_x_image (f, ximg, img->pixmap, width, height); | ||
| 3054 | x_destroy_x_image (ximg); | ||
| 3055 | return 1; | ||
| 3056 | |||
| 3057 | error: | ||
| 3058 | CloseComponent (gi); | ||
| 3059 | return 0; | ||
| 3060 | } | ||
| 3061 | |||
| 3062 | |||
| 3063 | /* Load an image using the QuickTime Graphics Importer. | ||
| 3064 | Note: The alpha channel does not work for PNG images. */ | ||
| 3065 | static int | ||
| 3066 | image_load_quicktime (f, img, type) | ||
| 3067 | struct frame *f; | ||
| 3068 | struct image *img; | ||
| 3069 | OSType type; | ||
| 3070 | { | ||
| 3071 | Lisp_Object specified_file; | ||
| 3072 | Lisp_Object specified_data; | ||
| 3073 | OSErr err; | ||
| 3074 | |||
| 3075 | specified_file = image_spec_value (img->spec, QCfile, NULL); | ||
| 3076 | specified_data = image_spec_value (img->spec, QCdata, NULL); | ||
| 3077 | |||
| 3078 | if (NILP (specified_data)) | ||
| 3079 | { | ||
| 3080 | /* Read from a file */ | ||
| 3081 | Lisp_Object file; | ||
| 3082 | FSSpec fss; | ||
| 3083 | |||
| 3084 | err = find_image_fsspec (specified_file, &file, &fss); | ||
| 3085 | if (err != noErr) | ||
| 3086 | { | ||
| 3087 | if (err == fnfErr) | ||
| 3088 | image_error ("Cannot find image file `%s'", specified_file, Qnil); | ||
| 3089 | else | ||
| 3090 | image_error ("Cannot open `%s'", file, Qnil); | ||
| 3091 | return 0; | ||
| 3092 | } | ||
| 3093 | return image_load_qt_1 (f, img, type, &fss, NULL); | ||
| 3094 | } | ||
| 3095 | else | ||
| 3096 | { | ||
| 3097 | /* Memory source! */ | ||
| 3098 | int success_p; | ||
| 3099 | Handle dh; | ||
| 3100 | |||
| 3101 | err = PtrToHand (SDATA (specified_data), &dh, SBYTES (specified_data)); | ||
| 3102 | if (err != noErr) | ||
| 3103 | { | ||
| 3104 | image_error ("Cannot allocate data handle for `%s'", | ||
| 3105 | img->spec, Qnil); | ||
| 3106 | return 0; | ||
| 3107 | } | ||
| 3108 | success_p = image_load_qt_1 (f, img, type, NULL, dh); | ||
| 3109 | DisposeHandle (dh); | ||
| 3110 | return success_p; | ||
| 3111 | } | ||
| 3112 | } | ||
| 3113 | |||
| 3114 | |||
| 3115 | #ifdef MAC_OSX | ||
| 3116 | static int | ||
| 3117 | image_load_quartz2d (f, img, png_p) | ||
| 3118 | struct frame *f; | ||
| 3119 | struct image *img; | ||
| 3120 | int png_p; | ||
| 3121 | { | ||
| 3122 | Lisp_Object file, specified_file; | ||
| 3123 | Lisp_Object specified_data, specified_bg; | ||
| 3124 | struct gcpro gcpro1; | ||
| 3125 | CGDataProviderRef source; | ||
| 3126 | CGImageRef image; | ||
| 3127 | int width, height; | ||
| 3128 | XColor color; | ||
| 3129 | XImagePtr ximg = NULL; | ||
| 3130 | CGContextRef context; | ||
| 3131 | CGRect rectangle; | ||
| 3132 | |||
| 3133 | /* Open the file. */ | ||
| 3134 | specified_file = image_spec_value (img->spec, QCfile, NULL); | ||
| 3135 | specified_data = image_spec_value (img->spec, QCdata, NULL); | ||
| 3136 | |||
| 3137 | file = Qnil; | ||
| 3138 | GCPRO1 (file); | ||
| 3139 | |||
| 3140 | if (NILP (specified_data)) | ||
| 3141 | { | ||
| 3142 | CFStringRef path; | ||
| 3143 | CFURLRef url; | ||
| 3144 | |||
| 3145 | file = x_find_image_file (specified_file); | ||
| 3146 | if (!STRINGP (file)) | ||
| 3147 | { | ||
| 3148 | image_error ("Cannot find image file `%s'", specified_file, Qnil); | ||
| 3149 | UNGCPRO; | ||
| 3150 | return 0; | ||
| 3151 | } | ||
| 3152 | path = cfstring_create_with_utf8_cstring (SDATA (file)); | ||
| 3153 | url = CFURLCreateWithFileSystemPath (NULL, path, | ||
| 3154 | kCFURLPOSIXPathStyle, 0); | ||
| 3155 | CFRelease (path); | ||
| 3156 | source = CGDataProviderCreateWithURL (url); | ||
| 3157 | CFRelease (url); | ||
| 3158 | } | ||
| 3159 | else | ||
| 3160 | source = CGDataProviderCreateWithData (NULL, SDATA (specified_data), | ||
| 3161 | SBYTES (specified_data), NULL); | ||
| 3162 | |||
| 3163 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 | ||
| 3164 | if (png_p) | ||
| 3165 | image = CGImageCreateWithPNGDataProvider (source, NULL, false, | ||
| 3166 | kCGRenderingIntentDefault); | ||
| 3167 | else | ||
| 3168 | #endif | ||
| 3169 | image = CGImageCreateWithJPEGDataProvider (source, NULL, false, | ||
| 3170 | kCGRenderingIntentDefault); | ||
| 3171 | |||
| 3172 | CGDataProviderRelease (source); | ||
| 3173 | if (image == NULL) | ||
| 3174 | { | ||
| 3175 | UNGCPRO; | ||
| 3176 | image_error ("Error reading image `%s'", img->spec, Qnil); | ||
| 3177 | return 0; | ||
| 3178 | } | ||
| 3179 | width = img->width = CGImageGetWidth (image); | ||
| 3180 | height = img->height = CGImageGetHeight (image); | ||
| 3181 | |||
| 3182 | if (!check_image_size (f, width, height)) | ||
| 3183 | { | ||
| 3184 | CGImageRelease (image); | ||
| 3185 | UNGCPRO; | ||
| 3186 | image_error ("Invalid image size", Qnil, Qnil); | ||
| 3187 | return 0; | ||
| 3188 | } | ||
| 3189 | |||
| 3190 | if (png_p) | ||
| 3191 | { | ||
| 3192 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | ||
| 3193 | if (!STRINGP (specified_bg) || | ||
| 3194 | !mac_defined_color (f, SDATA (specified_bg), &color, 0)) | ||
| 3195 | { | ||
| 3196 | color.pixel = FRAME_BACKGROUND_PIXEL (f); | ||
| 3197 | color.red = RED16_FROM_ULONG (color.pixel); | ||
| 3198 | color.green = GREEN16_FROM_ULONG (color.pixel); | ||
| 3199 | color.blue = BLUE16_FROM_ULONG (color.pixel); | ||
| 3200 | } | ||
| 3201 | } | ||
| 3202 | |||
| 3203 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) | ||
| 3204 | { | ||
| 3205 | CGImageRelease (image); | ||
| 3206 | UNGCPRO; | ||
| 3207 | return 0; | ||
| 3208 | } | ||
| 3209 | rectangle = CGRectMake (0, 0, width, height); | ||
| 3210 | QDBeginCGContext (ximg, &context); | ||
| 3211 | if (png_p) | ||
| 3212 | { | ||
| 3213 | CGContextSetRGBFillColor (context, color.red / 65535.0, | ||
| 3214 | color.green / 65535.0, | ||
| 3215 | color.blue / 65535.0, 1.0); | ||
| 3216 | CGContextFillRect (context, rectangle); | ||
| 3217 | } | ||
| 3218 | CGContextDrawImage (context, rectangle, image); | ||
| 3219 | QDEndCGContext (ximg, &context); | ||
| 3220 | CGImageRelease (image); | ||
| 3221 | |||
| 3222 | /* Maybe fill in the background field while we have ximg handy. */ | ||
| 3223 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | ||
| 3224 | IMAGE_BACKGROUND (img, f, ximg); | ||
| 3225 | |||
| 3226 | /* Put the image into the pixmap. */ | ||
| 3227 | x_put_x_image (f, ximg, img->pixmap, width, height); | ||
| 3228 | x_destroy_x_image (ximg); | ||
| 3229 | UNGCPRO; | ||
| 3230 | return 1; | ||
| 3231 | } | ||
| 3232 | #endif | ||
| 3233 | #endif /* !USE_MAC_IMAGE_IO */ | ||
| 3234 | |||
| 3235 | #endif /* MAC_OS */ | ||
| 3236 | |||
| 3237 | |||
| 3238 | /*********************************************************************** | 2533 | /*********************************************************************** |
| 3239 | XBM images | 2534 | XBM images |
| 3240 | ***********************************************************************/ | 2535 | ***********************************************************************/ |
| @@ -4011,13 +3306,13 @@ xbm_load (f, img) | |||
| 4011 | XPM images | 3306 | XPM images |
| 4012 | ***********************************************************************/ | 3307 | ***********************************************************************/ |
| 4013 | 3308 | ||
| 4014 | #if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS) | 3309 | #if defined (HAVE_XPM) || defined (HAVE_NS) |
| 4015 | 3310 | ||
| 4016 | static int xpm_image_p P_ ((Lisp_Object object)); | 3311 | static int xpm_image_p P_ ((Lisp_Object object)); |
| 4017 | static int xpm_load P_ ((struct frame *f, struct image *img)); | 3312 | static int xpm_load P_ ((struct frame *f, struct image *img)); |
| 4018 | static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); | 3313 | static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); |
| 4019 | 3314 | ||
| 4020 | #endif /* HAVE_XPM || MAC_OS || HAVE_NS */ | 3315 | #endif /* HAVE_XPM || HAVE_NS */ |
| 4021 | 3316 | ||
| 4022 | #ifdef HAVE_XPM | 3317 | #ifdef HAVE_XPM |
| 4023 | #ifdef HAVE_NTGUI | 3318 | #ifdef HAVE_NTGUI |
| @@ -4040,7 +3335,7 @@ static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); | |||
| 4040 | #endif /* HAVE_NTGUI */ | 3335 | #endif /* HAVE_NTGUI */ |
| 4041 | #endif /* HAVE_XPM */ | 3336 | #endif /* HAVE_XPM */ |
| 4042 | 3337 | ||
| 4043 | #if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS) | 3338 | #if defined (HAVE_XPM) || defined (HAVE_NS) |
| 4044 | /* The symbol `xpm' identifying XPM-format images. */ | 3339 | /* The symbol `xpm' identifying XPM-format images. */ |
| 4045 | 3340 | ||
| 4046 | Lisp_Object Qxpm; | 3341 | Lisp_Object Qxpm; |
| @@ -4367,7 +3662,7 @@ xpm_image_p (object) | |||
| 4367 | || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value))); | 3662 | || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value))); |
| 4368 | } | 3663 | } |
| 4369 | 3664 | ||
| 4370 | #endif /* HAVE_XPM || MAC_OS || HAVE_NS */ | 3665 | #endif /* HAVE_XPM || HAVE_NS */ |
| 4371 | 3666 | ||
| 4372 | #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) | 3667 | #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) |
| 4373 | int | 3668 | int |
| @@ -4646,9 +3941,9 @@ xpm_load (f, img) | |||
| 4646 | 3941 | ||
| 4647 | #endif /* HAVE_XPM */ | 3942 | #endif /* HAVE_XPM */ |
| 4648 | 3943 | ||
| 4649 | #if defined (MAC_OS) || ( defined (HAVE_NS) && !defined (HAVE_XPM) ) | 3944 | #if defined (HAVE_NS) && !defined (HAVE_XPM) |
| 4650 | 3945 | ||
| 4651 | /* XPM support functions for Mac OS where libxpm is not available. | 3946 | /* XPM support functions for NS where libxpm is not available. |
| 4652 | Only XPM version 3 (without any extensions) is supported. */ | 3947 | Only XPM version 3 (without any extensions) is supported. */ |
| 4653 | 3948 | ||
| 4654 | static int xpm_scan P_ ((const unsigned char **, const unsigned char *, | 3949 | static int xpm_scan P_ ((const unsigned char **, const unsigned char *, |
| @@ -5132,7 +4427,7 @@ xpm_load (f, img) | |||
| 5132 | return success_p; | 4427 | return success_p; |
| 5133 | } | 4428 | } |
| 5134 | 4429 | ||
| 5135 | #endif /* MAC_OS || (HAVE_NS && !HAVE_XPM) */ | 4430 | #endif /* HAVE_NS && !HAVE_XPM */ |
| 5136 | 4431 | ||
| 5137 | 4432 | ||
| 5138 | 4433 | ||
| @@ -5393,11 +4688,6 @@ lookup_rgb_color (f, r, g, b) | |||
| 5393 | { | 4688 | { |
| 5394 | unsigned long pixel; | 4689 | unsigned long pixel; |
| 5395 | 4690 | ||
| 5396 | #ifdef MAC_OS | ||
| 5397 | pixel = RGB_TO_ULONG (r >> 8, g >> 8, b >> 8); | ||
| 5398 | gamma_correct (f, &pixel); | ||
| 5399 | #endif /* MAC_OS */ | ||
| 5400 | |||
| 5401 | #ifdef HAVE_NTGUI | 4691 | #ifdef HAVE_NTGUI |
| 5402 | pixel = PALETTERGB (r >> 8, g >> 8, b >> 8); | 4692 | pixel = PALETTERGB (r >> 8, g >> 8, b >> 8); |
| 5403 | #endif /* HAVE_NTGUI */ | 4693 | #endif /* HAVE_NTGUI */ |
| @@ -5510,11 +4800,11 @@ x_to_xcolors (f, img, rgb_p) | |||
| 5510 | p->pixel = GET_PIXEL (ximg, x, y); | 4800 | p->pixel = GET_PIXEL (ximg, x, y); |
| 5511 | if (rgb_p) | 4801 | if (rgb_p) |
| 5512 | { | 4802 | { |
| 5513 | #if defined (MAC_OS) || defined (HAVE_NS) | 4803 | #if defined (HAVE_NS) |
| 5514 | p->red = RED16_FROM_ULONG (p->pixel); | 4804 | p->red = RED16_FROM_ULONG (p->pixel); |
| 5515 | p->green = GREEN16_FROM_ULONG (p->pixel); | 4805 | p->green = GREEN16_FROM_ULONG (p->pixel); |
| 5516 | p->blue = BLUE16_FROM_ULONG (p->pixel); | 4806 | p->blue = BLUE16_FROM_ULONG (p->pixel); |
| 5517 | #endif /* MAC_OS */ | 4807 | #endif /* HAVE_NS */ |
| 5518 | #ifdef HAVE_NTGUI | 4808 | #ifdef HAVE_NTGUI |
| 5519 | p->red = 256 * GetRValue (p->pixel); | 4809 | p->red = 256 * GetRValue (p->pixel); |
| 5520 | p->green = 256 * GetGValue (p->pixel); | 4810 | p->green = 256 * GetGValue (p->pixel); |
| @@ -5807,11 +5097,7 @@ x_disable_image (f, img) | |||
| 5807 | 5097 | ||
| 5808 | #ifndef HAVE_NS //TODO: NS support, however this not needed for toolbars | 5098 | #ifndef HAVE_NS //TODO: NS support, however this not needed for toolbars |
| 5809 | 5099 | ||
| 5810 | #ifdef MAC_OS | ||
| 5811 | #define MaskForeground(f) PIX_MASK_DRAW | ||
| 5812 | #else | ||
| 5813 | #define MaskForeground(f) WHITE_PIX_DEFAULT (f) | 5100 | #define MaskForeground(f) WHITE_PIX_DEFAULT (f) |
| 5814 | #endif | ||
| 5815 | 5101 | ||
| 5816 | gc = XCreateGC (dpy, img->pixmap, 0, NULL); | 5102 | gc = XCreateGC (dpy, img->pixmap, 0, NULL); |
| 5817 | XSetForeground (dpy, gc, BLACK_PIX_DEFAULT (f)); | 5103 | XSetForeground (dpy, gc, BLACK_PIX_DEFAULT (f)); |
| @@ -6422,7 +5708,7 @@ pbm_load (f, img) | |||
| 6422 | PNG | 5708 | PNG |
| 6423 | ***********************************************************************/ | 5709 | ***********************************************************************/ |
| 6424 | 5710 | ||
| 6425 | #if defined (HAVE_PNG) || defined (MAC_OS) || defined (HAVE_NS) | 5711 | #if defined (HAVE_PNG) || defined (HAVE_NS) |
| 6426 | 5712 | ||
| 6427 | /* Function prototypes. */ | 5713 | /* Function prototypes. */ |
| 6428 | 5714 | ||
| @@ -6494,7 +5780,7 @@ png_image_p (object) | |||
| 6494 | return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1; | 5780 | return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1; |
| 6495 | } | 5781 | } |
| 6496 | 5782 | ||
| 6497 | #endif /* HAVE_PNG || MAC_OS || HAVE_NS */ | 5783 | #endif /* HAVE_PNG || HAVE_NS */ |
| 6498 | 5784 | ||
| 6499 | 5785 | ||
| 6500 | #ifdef HAVE_PNG | 5786 | #ifdef HAVE_PNG |
| @@ -6882,19 +6168,6 @@ png_load (f, img) | |||
| 6882 | frame_background.blue = GetBValue (color); | 6168 | frame_background.blue = GetBValue (color); |
| 6883 | #endif /* HAVE_NTGUI */ | 6169 | #endif /* HAVE_NTGUI */ |
| 6884 | 6170 | ||
| 6885 | #ifdef MAC_OS | ||
| 6886 | unsigned long color; | ||
| 6887 | png_color_16 frame_background; | ||
| 6888 | color = FRAME_BACKGROUND_PIXEL (f); | ||
| 6889 | #if 0 /* MAC/W32 TODO : Colormap support. */ | ||
| 6890 | x_query_color (f, &color); | ||
| 6891 | #endif | ||
| 6892 | bzero (&frame_background, sizeof frame_background); | ||
| 6893 | frame_background.red = RED_FROM_ULONG (color); | ||
| 6894 | frame_background.green = GREEN_FROM_ULONG (color); | ||
| 6895 | frame_background.blue = BLUE_FROM_ULONG (color); | ||
| 6896 | #endif /* MAC_OS */ | ||
| 6897 | |||
| 6898 | fn_png_set_background (png_ptr, &frame_background, | 6171 | fn_png_set_background (png_ptr, &frame_background, |
| 6899 | PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); | 6172 | PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); |
| 6900 | } | 6173 | } |
| @@ -7038,22 +6311,6 @@ png_load (f, img) | |||
| 7038 | 6311 | ||
| 7039 | #else /* HAVE_PNG */ | 6312 | #else /* HAVE_PNG */ |
| 7040 | 6313 | ||
| 7041 | #ifdef MAC_OS | ||
| 7042 | static int | ||
| 7043 | png_load (f, img) | ||
| 7044 | struct frame *f; | ||
| 7045 | struct image *img; | ||
| 7046 | { | ||
| 7047 | #if USE_MAC_IMAGE_IO | ||
| 7048 | return image_load_image_io (f, img, kUTTypePNG); | ||
| 7049 | #elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 | ||
| 7050 | return image_load_quartz2d (f, img, 1); | ||
| 7051 | #else | ||
| 7052 | return image_load_quicktime (f, img, kQTFileTypePNG); | ||
| 7053 | #endif | ||
| 7054 | } | ||
| 7055 | #endif /* MAC_OS */ | ||
| 7056 | |||
| 7057 | #ifdef HAVE_NS | 6314 | #ifdef HAVE_NS |
| 7058 | static int | 6315 | static int |
| 7059 | png_load (struct frame *f, struct image *img) | 6316 | png_load (struct frame *f, struct image *img) |
| @@ -7073,7 +6330,7 @@ png_load (struct frame *f, struct image *img) | |||
| 7073 | JPEG | 6330 | JPEG |
| 7074 | ***********************************************************************/ | 6331 | ***********************************************************************/ |
| 7075 | 6332 | ||
| 7076 | #if defined (HAVE_JPEG) || defined (MAC_OS) || defined (HAVE_NS) | 6333 | #if defined (HAVE_JPEG) || defined (HAVE_NS) |
| 7077 | 6334 | ||
| 7078 | static int jpeg_image_p P_ ((Lisp_Object object)); | 6335 | static int jpeg_image_p P_ ((Lisp_Object object)); |
| 7079 | static int jpeg_load P_ ((struct frame *f, struct image *img)); | 6336 | static int jpeg_load P_ ((struct frame *f, struct image *img)); |
| @@ -7144,7 +6401,7 @@ jpeg_image_p (object) | |||
| 7144 | return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1; | 6401 | return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1; |
| 7145 | } | 6402 | } |
| 7146 | 6403 | ||
| 7147 | #endif /* HAVE_JPEG || MAC_OS || HAVE_NS */ | 6404 | #endif /* HAVE_JPEG || HAVE_NS */ |
| 7148 | 6405 | ||
| 7149 | #ifdef HAVE_JPEG | 6406 | #ifdef HAVE_JPEG |
| 7150 | 6407 | ||
| @@ -7628,22 +6885,6 @@ jpeg_load (f, img) | |||
| 7628 | 6885 | ||
| 7629 | #else /* HAVE_JPEG */ | 6886 | #else /* HAVE_JPEG */ |
| 7630 | 6887 | ||
| 7631 | #ifdef MAC_OS | ||
| 7632 | static int | ||
| 7633 | jpeg_load (f, img) | ||
| 7634 | struct frame *f; | ||
| 7635 | struct image *img; | ||
| 7636 | { | ||
| 7637 | #if USE_MAC_IMAGE_IO | ||
| 7638 | return image_load_image_io (f, img, kUTTypeJPEG); | ||
| 7639 | #elif defined (MAC_OSX) | ||
| 7640 | return image_load_quartz2d (f, img, 0); | ||
| 7641 | #else | ||
| 7642 | return image_load_quicktime (f, img, kQTFileTypeJPEG); | ||
| 7643 | #endif | ||
| 7644 | } | ||
| 7645 | #endif /* MAC_OS */ | ||
| 7646 | |||
| 7647 | #ifdef HAVE_NS | 6888 | #ifdef HAVE_NS |
| 7648 | static int | 6889 | static int |
| 7649 | jpeg_load (struct frame *f, struct image *img) | 6890 | jpeg_load (struct frame *f, struct image *img) |
| @@ -7662,7 +6903,7 @@ jpeg_load (struct frame *f, struct image *img) | |||
| 7662 | TIFF | 6903 | TIFF |
| 7663 | ***********************************************************************/ | 6904 | ***********************************************************************/ |
| 7664 | 6905 | ||
| 7665 | #if defined (HAVE_TIFF) || defined (MAC_OS) || defined (HAVE_NS) | 6906 | #if defined (HAVE_TIFF) || defined (HAVE_NS) |
| 7666 | 6907 | ||
| 7667 | static int tiff_image_p P_ ((Lisp_Object object)); | 6908 | static int tiff_image_p P_ ((Lisp_Object object)); |
| 7668 | static int tiff_load P_ ((struct frame *f, struct image *img)); | 6909 | static int tiff_load P_ ((struct frame *f, struct image *img)); |
| @@ -7732,7 +6973,7 @@ tiff_image_p (object) | |||
| 7732 | return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1; | 6973 | return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1; |
| 7733 | } | 6974 | } |
| 7734 | 6975 | ||
| 7735 | #endif /* HAVE_TIFF || MAC_OS || HAVE_NS */ | 6976 | #endif /* HAVE_TIFF || HAVE_NS */ |
| 7736 | 6977 | ||
| 7737 | #ifdef HAVE_TIFF | 6978 | #ifdef HAVE_TIFF |
| 7738 | 6979 | ||
| @@ -8065,20 +7306,6 @@ tiff_load (f, img) | |||
| 8065 | 7306 | ||
| 8066 | #else /* HAVE_TIFF */ | 7307 | #else /* HAVE_TIFF */ |
| 8067 | 7308 | ||
| 8068 | #ifdef MAC_OS | ||
| 8069 | static int | ||
| 8070 | tiff_load (f, img) | ||
| 8071 | struct frame *f; | ||
| 8072 | struct image *img; | ||
| 8073 | { | ||
| 8074 | #if USE_MAC_IMAGE_IO | ||
| 8075 | return image_load_image_io (f, img, kUTTypeTIFF); | ||
| 8076 | #else | ||
| 8077 | return image_load_quicktime (f, img, kQTFileTypeTIFF); | ||
| 8078 | #endif | ||
| 8079 | } | ||
| 8080 | #endif /* MAC_OS */ | ||
| 8081 | |||
| 8082 | #ifdef HAVE_NS | 7309 | #ifdef HAVE_NS |
| 8083 | static int | 7310 | static int |
| 8084 | tiff_load (struct frame *f, struct image *img) | 7311 | tiff_load (struct frame *f, struct image *img) |
| @@ -8097,7 +7324,7 @@ tiff_load (struct frame *f, struct image *img) | |||
| 8097 | GIF | 7324 | GIF |
| 8098 | ***********************************************************************/ | 7325 | ***********************************************************************/ |
| 8099 | 7326 | ||
| 8100 | #if defined (HAVE_GIF) || defined (MAC_OS) || defined (HAVE_NS) | 7327 | #if defined (HAVE_GIF) || defined (HAVE_NS) |
| 8101 | 7328 | ||
| 8102 | static int gif_image_p P_ ((Lisp_Object object)); | 7329 | static int gif_image_p P_ ((Lisp_Object object)); |
| 8103 | static int gif_load P_ ((struct frame *f, struct image *img)); | 7330 | static int gif_load P_ ((struct frame *f, struct image *img)); |
| @@ -8182,11 +7409,11 @@ gif_image_p (object) | |||
| 8182 | return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1; | 7409 | return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1; |
| 8183 | } | 7410 | } |
| 8184 | 7411 | ||
| 8185 | #endif /* HAVE_GIF || MAC_OS */ | 7412 | #endif /* HAVE_GIF */ |
| 8186 | 7413 | ||
| 8187 | #ifdef HAVE_GIF | 7414 | #ifdef HAVE_GIF |
| 8188 | 7415 | ||
| 8189 | #if defined (HAVE_NTGUI) || defined (MAC_OS) | 7416 | #if defined (HAVE_NTGUI) |
| 8190 | /* winuser.h might define DrawText to DrawTextA or DrawTextW. | 7417 | /* winuser.h might define DrawText to DrawTextA or DrawTextW. |
| 8191 | Undefine before redefining to avoid a preprocessor warning. */ | 7418 | Undefine before redefining to avoid a preprocessor warning. */ |
| 8192 | #ifdef DrawText | 7419 | #ifdef DrawText |
| @@ -8197,11 +7424,11 @@ gif_image_p (object) | |||
| 8197 | #include <gif_lib.h> | 7424 | #include <gif_lib.h> |
| 8198 | #undef DrawText | 7425 | #undef DrawText |
| 8199 | 7426 | ||
| 8200 | #else /* HAVE_NTGUI || MAC_OS */ | 7427 | #else /* HAVE_NTGUI */ |
| 8201 | 7428 | ||
| 8202 | #include <gif_lib.h> | 7429 | #include <gif_lib.h> |
| 8203 | 7430 | ||
| 8204 | #endif /* HAVE_NTGUI || MAC_OS */ | 7431 | #endif /* HAVE_NTGUI */ |
| 8205 | 7432 | ||
| 8206 | 7433 | ||
| 8207 | #ifdef HAVE_NTGUI | 7434 | #ifdef HAVE_NTGUI |
| @@ -8515,217 +7742,6 @@ gif_load (f, img) | |||
| 8515 | 7742 | ||
| 8516 | #else /* !HAVE_GIF */ | 7743 | #else /* !HAVE_GIF */ |
| 8517 | 7744 | ||
| 8518 | #ifdef MAC_OS | ||
| 8519 | static int | ||
| 8520 | gif_load (f, img) | ||
| 8521 | struct frame *f; | ||
| 8522 | struct image *img; | ||
| 8523 | { | ||
| 8524 | #if USE_MAC_IMAGE_IO | ||
| 8525 | return image_load_image_io (f, img, kUTTypeGIF); | ||
| 8526 | #else /* !USE_MAC_IMAGE_IO */ | ||
| 8527 | Lisp_Object specified_file, file; | ||
| 8528 | Lisp_Object specified_data; | ||
| 8529 | OSErr err; | ||
| 8530 | Boolean graphic_p, movie_p, prefer_graphic_p; | ||
| 8531 | Handle dh = NULL; | ||
| 8532 | Movie movie = NULL; | ||
| 8533 | Lisp_Object image; | ||
| 8534 | Track track = NULL; | ||
| 8535 | Media media = NULL; | ||
| 8536 | long nsamples; | ||
| 8537 | Rect rect; | ||
| 8538 | Lisp_Object specified_bg; | ||
| 8539 | XColor color; | ||
| 8540 | RGBColor bg_color; | ||
| 8541 | int width, height; | ||
| 8542 | XImagePtr ximg; | ||
| 8543 | TimeScale time_scale; | ||
| 8544 | TimeValue time, duration; | ||
| 8545 | int ino; | ||
| 8546 | CGrafPtr old_port; | ||
| 8547 | GDHandle old_gdh; | ||
| 8548 | |||
| 8549 | specified_file = image_spec_value (img->spec, QCfile, NULL); | ||
| 8550 | specified_data = image_spec_value (img->spec, QCdata, NULL); | ||
| 8551 | |||
| 8552 | /* Animated gifs use QuickTime Movie Toolbox. So initialize it here. */ | ||
| 8553 | EnterMovies (); | ||
| 8554 | |||
| 8555 | if (NILP (specified_data)) | ||
| 8556 | { | ||
| 8557 | /* Read from a file */ | ||
| 8558 | FSSpec fss; | ||
| 8559 | short refnum; | ||
| 8560 | |||
| 8561 | err = find_image_fsspec (specified_file, &file, &fss); | ||
| 8562 | if (err != noErr) | ||
| 8563 | { | ||
| 8564 | if (err == fnfErr) | ||
| 8565 | image_error ("Cannot find image file `%s'", specified_file, Qnil); | ||
| 8566 | else | ||
| 8567 | goto open_error; | ||
| 8568 | } | ||
| 8569 | |||
| 8570 | err = CanQuickTimeOpenFile (&fss, kQTFileTypeGIF, 0, | ||
| 8571 | &graphic_p, &movie_p, &prefer_graphic_p, 0); | ||
| 8572 | if (err != noErr) | ||
| 8573 | goto open_error; | ||
| 8574 | |||
| 8575 | if (!graphic_p && !movie_p) | ||
| 8576 | goto open_error; | ||
| 8577 | if (prefer_graphic_p) | ||
| 8578 | return image_load_qt_1 (f, img, kQTFileTypeGIF, &fss, NULL); | ||
| 8579 | err = OpenMovieFile (&fss, &refnum, fsRdPerm); | ||
| 8580 | if (err != noErr) | ||
| 8581 | goto open_error; | ||
| 8582 | err = NewMovieFromFile (&movie, refnum, NULL, NULL, 0, NULL); | ||
| 8583 | CloseMovieFile (refnum); | ||
| 8584 | if (err != noErr) | ||
| 8585 | { | ||
| 8586 | image_error ("Error reading `%s'", file, Qnil); | ||
| 8587 | return 0; | ||
| 8588 | } | ||
| 8589 | } | ||
| 8590 | else | ||
| 8591 | { | ||
| 8592 | /* Memory source! */ | ||
| 8593 | Handle dref = NULL; | ||
| 8594 | long file_type_atom[3]; | ||
| 8595 | |||
| 8596 | err = PtrToHand (SDATA (specified_data), &dh, SBYTES (specified_data)); | ||
| 8597 | if (err != noErr) | ||
| 8598 | { | ||
| 8599 | image_error ("Cannot allocate data handle for `%s'", | ||
| 8600 | img->spec, Qnil); | ||
| 8601 | goto error; | ||
| 8602 | } | ||
| 8603 | |||
| 8604 | file_type_atom[0] = EndianU32_NtoB (sizeof (long) * 3); | ||
| 8605 | file_type_atom[1] = EndianU32_NtoB (kDataRefExtensionMacOSFileType); | ||
| 8606 | file_type_atom[2] = EndianU32_NtoB (kQTFileTypeGIF); | ||
| 8607 | err = PtrToHand (&dh, &dref, sizeof (Handle)); | ||
| 8608 | if (err == noErr) | ||
| 8609 | /* no file name */ | ||
| 8610 | err = PtrAndHand ("\p", dref, 1); | ||
| 8611 | if (err == noErr) | ||
| 8612 | err = PtrAndHand (file_type_atom, dref, sizeof (long) * 3); | ||
| 8613 | if (err != noErr) | ||
| 8614 | { | ||
| 8615 | image_error ("Cannot allocate handle data ref for `%s'", img->spec, Qnil); | ||
| 8616 | goto error; | ||
| 8617 | } | ||
| 8618 | err = CanQuickTimeOpenDataRef (dref, HandleDataHandlerSubType, &graphic_p, | ||
| 8619 | &movie_p, &prefer_graphic_p, 0); | ||
| 8620 | if (err != noErr) | ||
| 8621 | goto open_error; | ||
| 8622 | |||
| 8623 | if (!graphic_p && !movie_p) | ||
| 8624 | goto open_error; | ||
| 8625 | if (prefer_graphic_p) | ||
| 8626 | { | ||
| 8627 | int success_p; | ||
| 8628 | |||
| 8629 | DisposeHandle (dref); | ||
| 8630 | success_p = image_load_qt_1 (f, img, kQTFileTypeGIF, NULL, dh); | ||
| 8631 | DisposeHandle (dh); | ||
| 8632 | return success_p; | ||
| 8633 | } | ||
| 8634 | err = NewMovieFromDataRef (&movie, 0, NULL, dref, | ||
| 8635 | HandleDataHandlerSubType); | ||
| 8636 | DisposeHandle (dref); | ||
| 8637 | if (err != noErr) | ||
| 8638 | goto open_error; | ||
| 8639 | } | ||
| 8640 | |||
| 8641 | image = image_spec_value (img->spec, QCindex, NULL); | ||
| 8642 | ino = INTEGERP (image) ? XFASTINT (image) : 0; | ||
| 8643 | track = GetMovieIndTrack (movie, 1); | ||
| 8644 | media = GetTrackMedia (track); | ||
| 8645 | nsamples = GetMediaSampleCount (media); | ||
| 8646 | if (ino >= nsamples) | ||
| 8647 | { | ||
| 8648 | image_error ("Invalid image number `%s' in image `%s'", | ||
| 8649 | image, img->spec); | ||
| 8650 | goto error; | ||
| 8651 | } | ||
| 8652 | time_scale = GetMediaTimeScale (media); | ||
| 8653 | |||
| 8654 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | ||
| 8655 | if (!STRINGP (specified_bg) | ||
| 8656 | || !mac_defined_color (f, SDATA (specified_bg), &color, 0)) | ||
| 8657 | { | ||
| 8658 | color.pixel = FRAME_BACKGROUND_PIXEL (f); | ||
| 8659 | color.red = RED16_FROM_ULONG (color.pixel); | ||
| 8660 | color.green = GREEN16_FROM_ULONG (color.pixel); | ||
| 8661 | color.blue = BLUE16_FROM_ULONG (color.pixel); | ||
| 8662 | } | ||
| 8663 | GetMovieBox (movie, &rect); | ||
| 8664 | width = img->width = rect.right - rect.left; | ||
| 8665 | height = img->height = rect.bottom - rect.top; | ||
| 8666 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) | ||
| 8667 | goto error; | ||
| 8668 | |||
| 8669 | GetGWorld (&old_port, &old_gdh); | ||
| 8670 | SetGWorld (ximg, NULL); | ||
| 8671 | bg_color.red = color.red; | ||
| 8672 | bg_color.green = color.green; | ||
| 8673 | bg_color.blue = color.blue; | ||
| 8674 | RGBBackColor (&bg_color); | ||
| 8675 | SetGWorld (old_port, old_gdh); | ||
| 8676 | SetMovieActive (movie, 1); | ||
| 8677 | SetMovieGWorld (movie, ximg, NULL); | ||
| 8678 | SampleNumToMediaTime (media, ino + 1, &time, &duration); | ||
| 8679 | SetMovieTimeValue (movie, time); | ||
| 8680 | MoviesTask (movie, 0L); | ||
| 8681 | DisposeTrackMedia (media); | ||
| 8682 | DisposeMovieTrack (track); | ||
| 8683 | DisposeMovie (movie); | ||
| 8684 | if (dh) | ||
| 8685 | DisposeHandle (dh); | ||
| 8686 | |||
| 8687 | /* Save GIF image extension data for `image-extension-data'. | ||
| 8688 | Format is (count IMAGES 0xf9 GRAPHIC_CONTROL_EXTENSION_BLOCK). */ | ||
| 8689 | { | ||
| 8690 | Lisp_Object gce = make_uninit_string (4); | ||
| 8691 | int centisec = ((float)duration / time_scale) * 100.0f + 0.5f; | ||
| 8692 | |||
| 8693 | /* Fill the delay time field. */ | ||
| 8694 | SSET (gce, 1, centisec & 0xff); | ||
| 8695 | SSET (gce, 2, (centisec >> 8) & 0xff); | ||
| 8696 | /* We don't know about other fields. */ | ||
| 8697 | SSET (gce, 0, 0); | ||
| 8698 | SSET (gce, 3, 0); | ||
| 8699 | |||
| 8700 | img->data.lisp_val = list4 (Qcount, make_number (nsamples), | ||
| 8701 | make_number (0xf9), gce); | ||
| 8702 | } | ||
| 8703 | |||
| 8704 | /* Maybe fill in the background field while we have ximg handy. */ | ||
| 8705 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | ||
| 8706 | IMAGE_BACKGROUND (img, f, ximg); | ||
| 8707 | |||
| 8708 | /* Put the image into the pixmap. */ | ||
| 8709 | x_put_x_image (f, ximg, img->pixmap, width, height); | ||
| 8710 | x_destroy_x_image (ximg); | ||
| 8711 | return 1; | ||
| 8712 | |||
| 8713 | open_error: | ||
| 8714 | image_error ("Cannot open `%s'", file, Qnil); | ||
| 8715 | error: | ||
| 8716 | if (media) | ||
| 8717 | DisposeTrackMedia (media); | ||
| 8718 | if (track) | ||
| 8719 | DisposeMovieTrack (track); | ||
| 8720 | if (movie) | ||
| 8721 | DisposeMovie (movie); | ||
| 8722 | if (dh) | ||
| 8723 | DisposeHandle (dh); | ||
| 8724 | return 0; | ||
| 8725 | #endif /* !USE_MAC_IMAGE_IO */ | ||
| 8726 | } | ||
| 8727 | #endif /* MAC_OS */ | ||
| 8728 | |||
| 8729 | #ifdef HAVE_NS | 7745 | #ifdef HAVE_NS |
| 8730 | static int | 7746 | static int |
| 8731 | gif_load (struct frame *f, struct image *img) | 7747 | gif_load (struct frame *f, struct image *img) |
| @@ -9069,11 +8085,6 @@ svg_load_image (f, img, contents, size) | |||
| 9069 | background.red >>= 8; | 8085 | background.red >>= 8; |
| 9070 | background.green >>= 8; | 8086 | background.green >>= 8; |
| 9071 | background.blue >>= 8; | 8087 | background.blue >>= 8; |
| 9072 | #elif defined (MAC_OS) | ||
| 9073 | background.pixel = FRAME_BACKGROUND_PIXEL (f); | ||
| 9074 | background.red = RED_FROM_ULONG (background.pixel); | ||
| 9075 | background.green = GREEN_FROM_ULONG (background.pixel); | ||
| 9076 | background.blue = BLUE_FROM_ULONG (background.pixel); | ||
| 9077 | #elif defined (HAVE_NTGUI) | 8088 | #elif defined (HAVE_NTGUI) |
| 9078 | background.pixel = FRAME_BACKGROUND_PIXEL (f); | 8089 | background.pixel = FRAME_BACKGROUND_PIXEL (f); |
| 9079 | #if 0 /* W32 TODO : Colormap support. */ | 8090 | #if 0 /* W32 TODO : Colormap support. */ |
| @@ -9086,7 +8097,7 @@ svg_load_image (f, img, contents, size) | |||
| 9086 | background.red >>= 8; | 8097 | background.red >>= 8; |
| 9087 | background.green >>= 8; | 8098 | background.green >>= 8; |
| 9088 | background.blue >>= 8; | 8099 | background.blue >>= 8; |
| 9089 | #else /* not HAVE_X_WINDOWS && not MAC_OS*/ | 8100 | #else /* not HAVE_X_WINDOWS*/ |
| 9090 | #error FIXME | 8101 | #error FIXME |
| 9091 | #endif | 8102 | #endif |
| 9092 | } | 8103 | } |
| @@ -9524,27 +8535,27 @@ of `image-library-alist', which see). */) | |||
| 9524 | if (CONSP (tested)) | 8535 | if (CONSP (tested)) |
| 9525 | return XCDR (tested); | 8536 | return XCDR (tested); |
| 9526 | 8537 | ||
| 9527 | #if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS) | 8538 | #if defined (HAVE_XPM) || defined (HAVE_NS) |
| 9528 | if (EQ (type, Qxpm)) | 8539 | if (EQ (type, Qxpm)) |
| 9529 | return CHECK_LIB_AVAILABLE (&xpm_type, init_xpm_functions, libraries); | 8540 | return CHECK_LIB_AVAILABLE (&xpm_type, init_xpm_functions, libraries); |
| 9530 | #endif | 8541 | #endif |
| 9531 | 8542 | ||
| 9532 | #if defined (HAVE_JPEG) || defined (MAC_OS) || defined (HAVE_NS) | 8543 | #if defined (HAVE_JPEG) || defined (HAVE_NS) |
| 9533 | if (EQ (type, Qjpeg)) | 8544 | if (EQ (type, Qjpeg)) |
| 9534 | return CHECK_LIB_AVAILABLE (&jpeg_type, init_jpeg_functions, libraries); | 8545 | return CHECK_LIB_AVAILABLE (&jpeg_type, init_jpeg_functions, libraries); |
| 9535 | #endif | 8546 | #endif |
| 9536 | 8547 | ||
| 9537 | #if defined (HAVE_TIFF) || defined (MAC_OS) || defined (HAVE_NS) | 8548 | #if defined (HAVE_TIFF) || defined (HAVE_NS) |
| 9538 | if (EQ (type, Qtiff)) | 8549 | if (EQ (type, Qtiff)) |
| 9539 | return CHECK_LIB_AVAILABLE (&tiff_type, init_tiff_functions, libraries); | 8550 | return CHECK_LIB_AVAILABLE (&tiff_type, init_tiff_functions, libraries); |
| 9540 | #endif | 8551 | #endif |
| 9541 | 8552 | ||
| 9542 | #if defined (HAVE_GIF) || defined (MAC_OS) || defined (HAVE_NS) | 8553 | #if defined (HAVE_GIF) || defined (HAVE_NS) |
| 9543 | if (EQ (type, Qgif)) | 8554 | if (EQ (type, Qgif)) |
| 9544 | return CHECK_LIB_AVAILABLE (&gif_type, init_gif_functions, libraries); | 8555 | return CHECK_LIB_AVAILABLE (&gif_type, init_gif_functions, libraries); |
| 9545 | #endif | 8556 | #endif |
| 9546 | 8557 | ||
| 9547 | #if defined (HAVE_PNG) || defined (MAC_OS) || defined (HAVE_NS) | 8558 | #if defined (HAVE_PNG) || defined (HAVE_NS) |
| 9548 | if (EQ (type, Qpng)) | 8559 | if (EQ (type, Qpng)) |
| 9549 | return CHECK_LIB_AVAILABLE (&png_type, init_png_functions, libraries); | 8560 | return CHECK_LIB_AVAILABLE (&png_type, init_png_functions, libraries); |
| 9550 | #endif | 8561 | #endif |
| @@ -9669,31 +8680,31 @@ non-numeric, there is no explicit limit on the size of images. */); | |||
| 9669 | staticpro (&QCpt_height); | 8680 | staticpro (&QCpt_height); |
| 9670 | #endif /* HAVE_GHOSTSCRIPT */ | 8681 | #endif /* HAVE_GHOSTSCRIPT */ |
| 9671 | 8682 | ||
| 9672 | #if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS) | 8683 | #if defined (HAVE_XPM) || defined (HAVE_NS) |
| 9673 | Qxpm = intern ("xpm"); | 8684 | Qxpm = intern ("xpm"); |
| 9674 | staticpro (&Qxpm); | 8685 | staticpro (&Qxpm); |
| 9675 | ADD_IMAGE_TYPE (Qxpm); | 8686 | ADD_IMAGE_TYPE (Qxpm); |
| 9676 | #endif | 8687 | #endif |
| 9677 | 8688 | ||
| 9678 | #if defined (HAVE_JPEG) || defined (MAC_OS) || defined (HAVE_NS) | 8689 | #if defined (HAVE_JPEG) || defined (HAVE_NS) |
| 9679 | Qjpeg = intern ("jpeg"); | 8690 | Qjpeg = intern ("jpeg"); |
| 9680 | staticpro (&Qjpeg); | 8691 | staticpro (&Qjpeg); |
| 9681 | ADD_IMAGE_TYPE (Qjpeg); | 8692 | ADD_IMAGE_TYPE (Qjpeg); |
| 9682 | #endif | 8693 | #endif |
| 9683 | 8694 | ||
| 9684 | #if defined (HAVE_TIFF) || defined (MAC_OS) || defined (HAVE_NS) | 8695 | #if defined (HAVE_TIFF) || defined (HAVE_NS) |
| 9685 | Qtiff = intern ("tiff"); | 8696 | Qtiff = intern ("tiff"); |
| 9686 | staticpro (&Qtiff); | 8697 | staticpro (&Qtiff); |
| 9687 | ADD_IMAGE_TYPE (Qtiff); | 8698 | ADD_IMAGE_TYPE (Qtiff); |
| 9688 | #endif | 8699 | #endif |
| 9689 | 8700 | ||
| 9690 | #if defined (HAVE_GIF) || defined (MAC_OS) || defined (HAVE_NS) | 8701 | #if defined (HAVE_GIF) || defined (HAVE_NS) |
| 9691 | Qgif = intern ("gif"); | 8702 | Qgif = intern ("gif"); |
| 9692 | staticpro (&Qgif); | 8703 | staticpro (&Qgif); |
| 9693 | ADD_IMAGE_TYPE (Qgif); | 8704 | ADD_IMAGE_TYPE (Qgif); |
| 9694 | #endif | 8705 | #endif |
| 9695 | 8706 | ||
| 9696 | #if defined (HAVE_PNG) || defined (MAC_OS) || defined (HAVE_NS) | 8707 | #if defined (HAVE_PNG) || defined (HAVE_NS) |
| 9697 | Qpng = intern ("png"); | 8708 | Qpng = intern ("png"); |
| 9698 | staticpro (&Qpng); | 8709 | staticpro (&Qpng); |
| 9699 | ADD_IMAGE_TYPE (Qpng); | 8710 | ADD_IMAGE_TYPE (Qpng); |