diff options
| author | Miles Bader | 2008-05-04 19:46:16 +0000 |
|---|---|---|
| committer | Miles Bader | 2008-05-04 19:46:16 +0000 |
| commit | f67e15be8d94718b2e2ea7da68eb0b2dc94ce016 (patch) | |
| tree | b7cdaa984d777c3bd0425f2ca2612d9a1de0d832 /src/image.c | |
| parent | f8a295058a5682dbc70f48f376fe51a18d21281a (diff) | |
| parent | 092a8af3e7cc0d72c417f9eb19c7ac61ef782a87 (diff) | |
| download | emacs-f67e15be8d94718b2e2ea7da68eb0b2dc94ce016.tar.gz emacs-f67e15be8d94718b2e2ea7da68eb0b2dc94ce016.zip | |
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1142
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 399 |
1 files changed, 359 insertions, 40 deletions
diff --git a/src/image.c b/src/image.c index fbf6a15cef6..48b223c6c76 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -115,10 +115,15 @@ typedef struct mac_bitmap_record Bitmap_Record; | |||
| 115 | 115 | ||
| 116 | #define RGB_PIXEL_COLOR unsigned long | 116 | #define RGB_PIXEL_COLOR unsigned long |
| 117 | 117 | ||
| 118 | #if USE_MAC_IMAGE_IO | ||
| 119 | #define PIX_MASK_DRAW 255 | ||
| 120 | #define PIX_MASK_RETAIN 0 | ||
| 121 | #else | ||
| 118 | /* A black pixel in a mask bitmap/pixmap means ``draw a source | 122 | /* A black pixel in a mask bitmap/pixmap means ``draw a source |
| 119 | pixel''. A white pixel means ``retain the current pixel''. */ | 123 | pixel''. A white pixel means ``retain the current pixel''. */ |
| 120 | #define PIX_MASK_DRAW RGB_TO_ULONG(0,0,0) | 124 | #define PIX_MASK_DRAW RGB_TO_ULONG(0,0,0) |
| 121 | #define PIX_MASK_RETAIN RGB_TO_ULONG(255,255,255) | 125 | #define PIX_MASK_RETAIN RGB_TO_ULONG(255,255,255) |
| 126 | #endif | ||
| 122 | 127 | ||
| 123 | #define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual | 128 | #define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual |
| 124 | #define x_defined_color mac_defined_color | 129 | #define x_defined_color mac_defined_color |
| @@ -166,6 +171,7 @@ XGetImage (display, pixmap, x, y, width, height, plane_mask, format) | |||
| 166 | unsigned long plane_mask; /* not used */ | 171 | unsigned long plane_mask; /* not used */ |
| 167 | int format; /* not used */ | 172 | int format; /* not used */ |
| 168 | { | 173 | { |
| 174 | #if !USE_MAC_IMAGE_IO | ||
| 169 | #if GLYPH_DEBUG | 175 | #if GLYPH_DEBUG |
| 170 | xassert (x == 0 && y == 0); | 176 | xassert (x == 0 && y == 0); |
| 171 | { | 177 | { |
| @@ -177,6 +183,7 @@ XGetImage (display, pixmap, x, y, width, height, plane_mask, format) | |||
| 177 | #endif | 183 | #endif |
| 178 | 184 | ||
| 179 | LockPixels (GetGWorldPixMap (pixmap)); | 185 | LockPixels (GetGWorldPixMap (pixmap)); |
| 186 | #endif | ||
| 180 | 187 | ||
| 181 | return pixmap; | 188 | return pixmap; |
| 182 | } | 189 | } |
| @@ -187,6 +194,12 @@ XPutPixel (ximage, x, y, pixel) | |||
| 187 | int x, y; | 194 | int x, y; |
| 188 | unsigned long pixel; | 195 | unsigned long pixel; |
| 189 | { | 196 | { |
| 197 | #if USE_MAC_IMAGE_IO | ||
| 198 | if (ximage->bits_per_pixel == 32) | ||
| 199 | ((unsigned int *)(ximage->data + y * ximage->bytes_per_line))[x] = pixel; | ||
| 200 | else | ||
| 201 | ((unsigned char *)(ximage->data + y * ximage->bytes_per_line))[x] = pixel; | ||
| 202 | #else | ||
| 190 | PixMapHandle pixmap = GetGWorldPixMap (ximage); | 203 | PixMapHandle pixmap = GetGWorldPixMap (ximage); |
| 191 | short depth = GetPixDepth (pixmap); | 204 | short depth = GetPixDepth (pixmap); |
| 192 | 205 | ||
| @@ -227,6 +240,7 @@ XPutPixel (ximage, x, y, pixel) | |||
| 227 | 240 | ||
| 228 | SetGWorld (old_port, old_gdh); | 241 | SetGWorld (old_port, old_gdh); |
| 229 | } | 242 | } |
| 243 | #endif | ||
| 230 | } | 244 | } |
| 231 | 245 | ||
| 232 | static unsigned long | 246 | static unsigned long |
| @@ -234,6 +248,12 @@ XGetPixel (ximage, x, y) | |||
| 234 | XImagePtr ximage; | 248 | XImagePtr ximage; |
| 235 | int x, y; | 249 | int x, y; |
| 236 | { | 250 | { |
| 251 | #if USE_MAC_IMAGE_IO | ||
| 252 | if (ximage->bits_per_pixel == 32) | ||
| 253 | return ((unsigned int *)(ximage->data + y * ximage->bytes_per_line))[x]; | ||
| 254 | else | ||
| 255 | return ((unsigned char *)(ximage->data + y * ximage->bytes_per_line))[x]; | ||
| 256 | #else | ||
| 237 | PixMapHandle pixmap = GetGWorldPixMap (ximage); | 257 | PixMapHandle pixmap = GetGWorldPixMap (ximage); |
| 238 | short depth = GetPixDepth (pixmap); | 258 | short depth = GetPixDepth (pixmap); |
| 239 | 259 | ||
| @@ -271,21 +291,80 @@ XGetPixel (ximage, x, y) | |||
| 271 | SetGWorld (old_port, old_gdh); | 291 | SetGWorld (old_port, old_gdh); |
| 272 | return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8); | 292 | return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8); |
| 273 | } | 293 | } |
| 294 | #endif | ||
| 274 | } | 295 | } |
| 275 | 296 | ||
| 276 | static void | 297 | static void |
| 277 | XDestroyImage (ximg) | 298 | XDestroyImage (ximg) |
| 278 | XImagePtr ximg; | 299 | XImagePtr ximg; |
| 279 | { | 300 | { |
| 301 | #if !USE_MAC_IMAGE_IO | ||
| 280 | UnlockPixels (GetGWorldPixMap (ximg)); | 302 | UnlockPixels (GetGWorldPixMap (ximg)); |
| 303 | #endif | ||
| 281 | } | 304 | } |
| 282 | 305 | ||
| 283 | #if USE_CG_DRAWING | 306 | #if USE_CG_DRAWING |
| 307 | #if USE_MAC_IMAGE_IO | ||
| 308 | void | ||
| 309 | mac_data_provider_release_data (info, data, size) | ||
| 310 | void *info; | ||
| 311 | const void *data; | ||
| 312 | size_t size; | ||
| 313 | { | ||
| 314 | xfree ((void *)data); | ||
| 315 | } | ||
| 316 | #endif | ||
| 317 | |||
| 284 | static CGImageRef | 318 | static CGImageRef |
| 285 | mac_create_cg_image_from_image (f, img) | 319 | mac_create_cg_image_from_image (f, img) |
| 286 | struct frame *f; | 320 | struct frame *f; |
| 287 | struct image *img; | 321 | struct image *img; |
| 288 | { | 322 | { |
| 323 | #if USE_MAC_IMAGE_IO | ||
| 324 | XImagePtr ximg = img->pixmap; | ||
| 325 | CGDataProviderRef provider; | ||
| 326 | CGImageRef result; | ||
| 327 | |||
| 328 | if (img->mask) | ||
| 329 | { | ||
| 330 | int x, y; | ||
| 331 | unsigned long color, alpha; | ||
| 332 | |||
| 333 | for (y = 0; y < ximg->height; y++) | ||
| 334 | for (x = 0; x < ximg->width; x++) | ||
| 335 | { | ||
| 336 | color = XGetPixel (ximg, x, y); | ||
| 337 | alpha = XGetPixel (img->mask, x, y); | ||
| 338 | XPutPixel (ximg, x, y, | ||
| 339 | ARGB_TO_ULONG (alpha, | ||
| 340 | RED_FROM_ULONG (color) | ||
| 341 | * alpha / PIX_MASK_DRAW, | ||
| 342 | GREEN_FROM_ULONG (color) | ||
| 343 | * alpha / PIX_MASK_DRAW, | ||
| 344 | BLUE_FROM_ULONG (color) | ||
| 345 | * alpha / PIX_MASK_DRAW)); | ||
| 346 | } | ||
| 347 | xfree (img->mask->data); | ||
| 348 | img->mask->data = NULL; | ||
| 349 | } | ||
| 350 | BLOCK_INPUT; | ||
| 351 | provider = CGDataProviderCreateWithData (NULL, ximg->data, | ||
| 352 | ximg->bytes_per_line * ximg->height, | ||
| 353 | mac_data_provider_release_data); | ||
| 354 | ximg->data = NULL; | ||
| 355 | result = CGImageCreate (ximg->width, ximg->height, 8, 32, | ||
| 356 | ximg->bytes_per_line, mac_cg_color_space_rgb, | ||
| 357 | (img->mask ? kCGImageAlphaPremultipliedFirst | ||
| 358 | : kCGImageAlphaNoneSkipFirst) | ||
| 359 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 | ||
| 360 | | kCGBitmapByteOrder32Host | ||
| 361 | #endif | ||
| 362 | , provider, NULL, 0, kCGRenderingIntentDefault); | ||
| 363 | CGDataProviderRelease (provider); | ||
| 364 | UNBLOCK_INPUT; | ||
| 365 | |||
| 366 | return result; | ||
| 367 | #else | ||
| 289 | Pixmap mask; | 368 | Pixmap mask; |
| 290 | CGImageRef result = NULL; | 369 | CGImageRef result = NULL; |
| 291 | 370 | ||
| @@ -320,6 +399,7 @@ mac_create_cg_image_from_image (f, img) | |||
| 320 | UNBLOCK_INPUT; | 399 | UNBLOCK_INPUT; |
| 321 | 400 | ||
| 322 | return result; | 401 | return result; |
| 402 | #endif | ||
| 323 | } | 403 | } |
| 324 | #endif /* USE_CG_DRAWING */ | 404 | #endif /* USE_CG_DRAWING */ |
| 325 | #endif /* MAC_OS */ | 405 | #endif /* MAC_OS */ |
| @@ -2301,7 +2381,9 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) | |||
| 2301 | return 0; | 2381 | return 0; |
| 2302 | } | 2382 | } |
| 2303 | 2383 | ||
| 2384 | #if !USE_MAC_IMAGE_IO | ||
| 2304 | LockPixels (GetGWorldPixMap (*pixmap)); | 2385 | LockPixels (GetGWorldPixMap (*pixmap)); |
| 2386 | #endif | ||
| 2305 | *ximg = *pixmap; | 2387 | *ximg = *pixmap; |
| 2306 | return 1; | 2388 | return 1; |
| 2307 | 2389 | ||
| @@ -2454,6 +2536,256 @@ slurp_file (file, size) | |||
| 2454 | MAC Image Load Functions | 2536 | MAC Image Load Functions |
| 2455 | ***********************************************************************/ | 2537 | ***********************************************************************/ |
| 2456 | 2538 | ||
| 2539 | #if USE_MAC_IMAGE_IO | ||
| 2540 | static int | ||
| 2541 | image_load_image_io (f, img, type) | ||
| 2542 | struct frame *f; | ||
| 2543 | struct image *img; | ||
| 2544 | CFStringRef type; | ||
| 2545 | { | ||
| 2546 | CFDictionaryRef options, src_props = NULL, props = NULL; | ||
| 2547 | CFStringRef keys[2]; | ||
| 2548 | CFTypeRef values[2]; | ||
| 2549 | Lisp_Object specified_file, specified_data; | ||
| 2550 | CGImageSourceRef source = NULL; | ||
| 2551 | size_t count; | ||
| 2552 | CGImageRef image = NULL; | ||
| 2553 | int loop_count = -1; | ||
| 2554 | double delay_time = -1.0; | ||
| 2555 | int width, height; | ||
| 2556 | XImagePtr ximg = NULL; | ||
| 2557 | CGContextRef context; | ||
| 2558 | CGRect rectangle; | ||
| 2559 | int has_alpha_p, gif_p; | ||
| 2560 | |||
| 2561 | gif_p = UTTypeEqual (type, kUTTypeGIF); | ||
| 2562 | |||
| 2563 | keys[0] = kCGImageSourceTypeIdentifierHint; | ||
| 2564 | values[0] = (CFTypeRef) type; | ||
| 2565 | keys[1] = kCGImageSourceShouldCache; | ||
| 2566 | values[1] = (CFTypeRef) kCFBooleanFalse; | ||
| 2567 | options = CFDictionaryCreate (NULL, (const void **) keys, | ||
| 2568 | (const void **) values, | ||
| 2569 | sizeof (keys) / sizeof (keys[0]), | ||
| 2570 | &kCFTypeDictionaryKeyCallBacks, | ||
| 2571 | &kCFTypeDictionaryValueCallBacks); | ||
| 2572 | if (options == NULL) | ||
| 2573 | { | ||
| 2574 | image_error ("Error creating options for image `%s'", img->spec, Qnil); | ||
| 2575 | return 0; | ||
| 2576 | } | ||
| 2577 | |||
| 2578 | /* Open the file. */ | ||
| 2579 | specified_file = image_spec_value (img->spec, QCfile, NULL); | ||
| 2580 | specified_data = image_spec_value (img->spec, QCdata, NULL); | ||
| 2581 | |||
| 2582 | if (NILP (specified_data)) | ||
| 2583 | { | ||
| 2584 | Lisp_Object file; | ||
| 2585 | CFStringRef path; | ||
| 2586 | CFURLRef url; | ||
| 2587 | |||
| 2588 | file = x_find_image_file (specified_file); | ||
| 2589 | if (!STRINGP (file)) | ||
| 2590 | { | ||
| 2591 | image_error ("Cannot find image file `%s'", specified_file, Qnil); | ||
| 2592 | return 0; | ||
| 2593 | } | ||
| 2594 | path = cfstring_create_with_utf8_cstring (SDATA (file)); | ||
| 2595 | if (path) | ||
| 2596 | { | ||
| 2597 | url = CFURLCreateWithFileSystemPath (NULL, path, | ||
| 2598 | kCFURLPOSIXPathStyle, 0); | ||
| 2599 | CFRelease (path); | ||
| 2600 | if (url) | ||
| 2601 | { | ||
| 2602 | source = CGImageSourceCreateWithURL (url, NULL); | ||
| 2603 | CFRelease (url); | ||
| 2604 | } | ||
| 2605 | } | ||
| 2606 | } | ||
| 2607 | else | ||
| 2608 | { | ||
| 2609 | CFDataRef data = CFDataCreate (NULL, SDATA (specified_data), | ||
| 2610 | SBYTES (specified_data)); | ||
| 2611 | |||
| 2612 | if (data) | ||
| 2613 | { | ||
| 2614 | source = CGImageSourceCreateWithData (data, options); | ||
| 2615 | CFRelease (data); | ||
| 2616 | } | ||
| 2617 | } | ||
| 2618 | CFRelease (options); | ||
| 2619 | |||
| 2620 | if (source) | ||
| 2621 | { | ||
| 2622 | CFStringRef real_type = CGImageSourceGetType (source); | ||
| 2623 | |||
| 2624 | if (real_type && UTTypeEqual (type, real_type)) | ||
| 2625 | src_props = CGImageSourceCopyProperties (source, NULL); | ||
| 2626 | if (src_props) | ||
| 2627 | { | ||
| 2628 | EMACS_INT ino = 0; | ||
| 2629 | |||
| 2630 | count = CGImageSourceGetCount (source); | ||
| 2631 | if (gif_p) | ||
| 2632 | { | ||
| 2633 | Lisp_Object image = image_spec_value (img->spec, QCindex, NULL); | ||
| 2634 | |||
| 2635 | if (INTEGERP (image)) | ||
| 2636 | ino = XFASTINT (image); | ||
| 2637 | } | ||
| 2638 | if (ino >= 0 && ino < count) | ||
| 2639 | { | ||
| 2640 | props = CGImageSourceCopyPropertiesAtIndex (source, ino, NULL); | ||
| 2641 | if (props) | ||
| 2642 | image = CGImageSourceCreateImageAtIndex (source, ino, NULL); | ||
| 2643 | } | ||
| 2644 | } | ||
| 2645 | CFRelease (source); | ||
| 2646 | } | ||
| 2647 | |||
| 2648 | if (image == NULL) | ||
| 2649 | { | ||
| 2650 | if (src_props) | ||
| 2651 | CFRelease (src_props); | ||
| 2652 | if (props) | ||
| 2653 | CFRelease (props); | ||
| 2654 | image_error ("Error reading image `%s'", img->spec, Qnil); | ||
| 2655 | return 0; | ||
| 2656 | } | ||
| 2657 | else | ||
| 2658 | { | ||
| 2659 | CFBooleanRef boolean; | ||
| 2660 | |||
| 2661 | if (CFDictionaryGetValueIfPresent (props, kCGImagePropertyHasAlpha, | ||
| 2662 | (const void **) &boolean)) | ||
| 2663 | has_alpha_p = CFBooleanGetValue (boolean); | ||
| 2664 | if (gif_p) | ||
| 2665 | { | ||
| 2666 | CFDictionaryRef dict; | ||
| 2667 | CFNumberRef number; | ||
| 2668 | |||
| 2669 | dict = CFDictionaryGetValue (src_props, | ||
| 2670 | kCGImagePropertyGIFDictionary); | ||
| 2671 | if (dict | ||
| 2672 | && CFDictionaryGetValueIfPresent (dict, | ||
| 2673 | kCGImagePropertyGIFLoopCount, | ||
| 2674 | (const void **) &number)) | ||
| 2675 | CFNumberGetValue (number, kCFNumberIntType, &loop_count); | ||
| 2676 | |||
| 2677 | dict = CFDictionaryGetValue (props, kCGImagePropertyGIFDictionary); | ||
| 2678 | if (dict | ||
| 2679 | && CFDictionaryGetValueIfPresent (dict, | ||
| 2680 | kCGImagePropertyGIFDelayTime, | ||
| 2681 | (const void **) &number)) | ||
| 2682 | CFNumberGetValue (number, kCFNumberDoubleType, &delay_time); | ||
| 2683 | } | ||
| 2684 | CFRelease (src_props); | ||
| 2685 | CFRelease (props); | ||
| 2686 | } | ||
| 2687 | |||
| 2688 | width = img->width = CGImageGetWidth (image); | ||
| 2689 | height = img->height = CGImageGetHeight (image); | ||
| 2690 | |||
| 2691 | if (!check_image_size (f, width, height)) | ||
| 2692 | { | ||
| 2693 | CGImageRelease (image); | ||
| 2694 | image_error ("Invalid image size", Qnil, Qnil); | ||
| 2695 | return 0; | ||
| 2696 | } | ||
| 2697 | |||
| 2698 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) | ||
| 2699 | { | ||
| 2700 | CGImageRelease (image); | ||
| 2701 | image_error ("Out of memory (%s)", img->spec, Qnil); | ||
| 2702 | return 0; | ||
| 2703 | } | ||
| 2704 | rectangle = CGRectMake (0, 0, width, height); | ||
| 2705 | |||
| 2706 | context = CGBitmapContextCreate (ximg->data, ximg->width, ximg->height, 8, | ||
| 2707 | ximg->bytes_per_line, | ||
| 2708 | mac_cg_color_space_rgb, | ||
| 2709 | kCGImageAlphaNoneSkipFirst | ||
| 2710 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 | ||
| 2711 | | kCGBitmapByteOrder32Host | ||
| 2712 | #endif | ||
| 2713 | ); | ||
| 2714 | if (has_alpha_p) | ||
| 2715 | { | ||
| 2716 | Lisp_Object specified_bg; | ||
| 2717 | XColor color; | ||
| 2718 | |||
| 2719 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | ||
| 2720 | if (!STRINGP (specified_bg) | ||
| 2721 | || !mac_defined_color (f, SDATA (specified_bg), &color, 0)) | ||
| 2722 | { | ||
| 2723 | color.pixel = FRAME_BACKGROUND_PIXEL (f); | ||
| 2724 | color.red = RED16_FROM_ULONG (color.pixel); | ||
| 2725 | color.green = GREEN16_FROM_ULONG (color.pixel); | ||
| 2726 | color.blue = BLUE16_FROM_ULONG (color.pixel); | ||
| 2727 | } | ||
| 2728 | CGContextSetRGBFillColor (context, color.red / 65535.0, | ||
| 2729 | color.green / 65535.0, | ||
| 2730 | color.blue / 65535.0, 1.0); | ||
| 2731 | CGContextFillRect (context, rectangle); | ||
| 2732 | } | ||
| 2733 | CGContextDrawImage (context, rectangle, image); | ||
| 2734 | CGContextRelease (context); | ||
| 2735 | CGImageRelease (image); | ||
| 2736 | |||
| 2737 | /* Save GIF image extension data for `image-extension-data'. | ||
| 2738 | Format is (count IMAGES | ||
| 2739 | 0xff "NETSCAPE2.0" 0x00 DATA_SUB_BLOCK_FOR_LOOP_COUNT | ||
| 2740 | 0xf9 GRAPHIC_CONTROL_EXTENSION_BLOCK). */ | ||
| 2741 | if (gif_p) | ||
| 2742 | { | ||
| 2743 | img->data.lisp_val = Qnil; | ||
| 2744 | if (delay_time >= 0) | ||
| 2745 | { | ||
| 2746 | Lisp_Object gce = make_uninit_string (4); | ||
| 2747 | int centisec = delay_time * 100.0 + 0.5; | ||
| 2748 | |||
| 2749 | /* Fill the delay time field. */ | ||
| 2750 | SSET (gce, 1, centisec & 0xff); | ||
| 2751 | SSET (gce, 2, (centisec >> 8) & 0xff); | ||
| 2752 | /* We don't know about other fields. */ | ||
| 2753 | SSET (gce, 0, 0); | ||
| 2754 | SSET (gce, 3, 0); | ||
| 2755 | img->data.lisp_val = Fcons (make_number (0xf9), | ||
| 2756 | Fcons (gce, | ||
| 2757 | img->data.lisp_val)); | ||
| 2758 | } | ||
| 2759 | if (loop_count >= 0) | ||
| 2760 | { | ||
| 2761 | Lisp_Object data_sub_block = make_uninit_string (3); | ||
| 2762 | |||
| 2763 | SSET (data_sub_block, 0, 0x01); | ||
| 2764 | SSET (data_sub_block, 1, loop_count & 0xff); | ||
| 2765 | SSET (data_sub_block, 2, (loop_count >> 8) & 0xff); | ||
| 2766 | img->data.lisp_val = Fcons (make_number (0), | ||
| 2767 | Fcons (data_sub_block, | ||
| 2768 | img->data.lisp_val)); | ||
| 2769 | img->data.lisp_val = Fcons (make_number (0xff), | ||
| 2770 | Fcons (build_string ("NETSCAPE2.0"), | ||
| 2771 | img->data.lisp_val)); | ||
| 2772 | } | ||
| 2773 | if (count > 1) | ||
| 2774 | img->data.lisp_val = Fcons (Qcount, | ||
| 2775 | Fcons (make_number (count), | ||
| 2776 | img->data.lisp_val)); | ||
| 2777 | } | ||
| 2778 | |||
| 2779 | /* Maybe fill in the background field while we have ximg handy. */ | ||
| 2780 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | ||
| 2781 | IMAGE_BACKGROUND (img, f, ximg); | ||
| 2782 | |||
| 2783 | /* Put the image into the pixmap. */ | ||
| 2784 | x_put_x_image (f, ximg, img->pixmap, width, height); | ||
| 2785 | x_destroy_x_image (ximg); | ||
| 2786 | return 1; | ||
| 2787 | } | ||
| 2788 | #else /* !USE_MAC_IMAGE_IO */ | ||
| 2457 | static int image_load_quicktime P_ ((struct frame *, struct image *img, | 2789 | static int image_load_quicktime P_ ((struct frame *, struct image *img, |
| 2458 | OSType)); | 2790 | OSType)); |
| 2459 | #ifdef MAC_OSX | 2791 | #ifdef MAC_OSX |
| @@ -2666,30 +2998,6 @@ image_load_quicktime (f, img, type) | |||
| 2666 | 2998 | ||
| 2667 | 2999 | ||
| 2668 | #ifdef MAC_OSX | 3000 | #ifdef MAC_OSX |
| 2669 | /* Load a PNG/JPEG image using Quartz 2D decoding routines. | ||
| 2670 | CGImageCreateWithPNGDataProvider is provided after Mac OS X 10.2. | ||
| 2671 | So don't use this function directly but determine at runtime | ||
| 2672 | whether it exists. */ | ||
| 2673 | typedef CGImageRef (*CGImageCreateWithPNGDataProviderProcType) | ||
| 2674 | (CGDataProviderRef, const float [], bool, CGColorRenderingIntent); | ||
| 2675 | static CGImageCreateWithPNGDataProviderProcType MyCGImageCreateWithPNGDataProvider; | ||
| 2676 | |||
| 2677 | |||
| 2678 | static void | ||
| 2679 | init_image_func_pointer () | ||
| 2680 | { | ||
| 2681 | if (NSIsSymbolNameDefined ("_CGImageCreateWithPNGDataProvider")) | ||
| 2682 | { | ||
| 2683 | MyCGImageCreateWithPNGDataProvider | ||
| 2684 | = (CGImageCreateWithPNGDataProviderProcType) | ||
| 2685 | NSAddressOfSymbol (NSLookupAndBindSymbol | ||
| 2686 | ("_CGImageCreateWithPNGDataProvider")); | ||
| 2687 | } | ||
| 2688 | else | ||
| 2689 | MyCGImageCreateWithPNGDataProvider = NULL; | ||
| 2690 | } | ||
| 2691 | |||
| 2692 | |||
| 2693 | static int | 3001 | static int |
| 2694 | image_load_quartz2d (f, img, png_p) | 3002 | image_load_quartz2d (f, img, png_p) |
| 2695 | struct frame *f; | 3003 | struct frame *f; |
| @@ -2737,11 +3045,13 @@ image_load_quartz2d (f, img, png_p) | |||
| 2737 | source = CGDataProviderCreateWithData (NULL, SDATA (specified_data), | 3045 | source = CGDataProviderCreateWithData (NULL, SDATA (specified_data), |
| 2738 | SBYTES (specified_data), NULL); | 3046 | SBYTES (specified_data), NULL); |
| 2739 | 3047 | ||
| 3048 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 | ||
| 2740 | if (png_p) | 3049 | if (png_p) |
| 2741 | image = (*MyCGImageCreateWithPNGDataProvider) (source, NULL, FALSE, | 3050 | image = CGImageCreateWithPNGDataProvider (source, NULL, false, |
| 2742 | kCGRenderingIntentDefault); | 3051 | kCGRenderingIntentDefault); |
| 2743 | else | 3052 | else |
| 2744 | image = CGImageCreateWithJPEGDataProvider (source, NULL, FALSE, | 3053 | #endif |
| 3054 | image = CGImageCreateWithJPEGDataProvider (source, NULL, false, | ||
| 2745 | kCGRenderingIntentDefault); | 3055 | kCGRenderingIntentDefault); |
| 2746 | 3056 | ||
| 2747 | CGDataProviderRelease (source); | 3057 | CGDataProviderRelease (source); |
| @@ -2805,6 +3115,7 @@ image_load_quartz2d (f, img, png_p) | |||
| 2805 | return 1; | 3115 | return 1; |
| 2806 | } | 3116 | } |
| 2807 | #endif | 3117 | #endif |
| 3118 | #endif /* !USE_MAC_IMAGE_IO */ | ||
| 2808 | 3119 | ||
| 2809 | #endif /* MAC_OS */ | 3120 | #endif /* MAC_OS */ |
| 2810 | 3121 | ||
| @@ -4275,8 +4586,8 @@ xpm_scan (s, end, beg, len) | |||
| 4275 | if (isalpha (c) || c == '_' || c == '-' || c == '+') | 4586 | if (isalpha (c) || c == '_' || c == '-' || c == '+') |
| 4276 | { | 4587 | { |
| 4277 | *beg = *s - 1; | 4588 | *beg = *s - 1; |
| 4278 | while (*s < end && | 4589 | while (*s < end |
| 4279 | (c = **s, isalnum (c) || c == '_' || c == '-' || c == '+')) | 4590 | && (c = **s, isalnum (c) || c == '_' || c == '-' || c == '+')) |
| 4280 | ++*s; | 4591 | ++*s; |
| 4281 | *len = *s - *beg; | 4592 | *len = *s - *beg; |
| 4282 | return XPM_TK_IDENT; | 4593 | return XPM_TK_IDENT; |
| @@ -6622,12 +6933,13 @@ png_load (f, img) | |||
| 6622 | struct frame *f; | 6933 | struct frame *f; |
| 6623 | struct image *img; | 6934 | struct image *img; |
| 6624 | { | 6935 | { |
| 6625 | #ifdef MAC_OSX | 6936 | #if USE_MAC_IMAGE_IO |
| 6626 | if (MyCGImageCreateWithPNGDataProvider) | 6937 | return image_load_image_io (f, img, kUTTypePNG); |
| 6627 | return image_load_quartz2d (f, img, 1); | 6938 | #elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 |
| 6628 | else | 6939 | return image_load_quartz2d (f, img, 1); |
| 6940 | #else | ||
| 6941 | return image_load_quicktime (f, img, kQTFileTypePNG); | ||
| 6629 | #endif | 6942 | #endif |
| 6630 | return image_load_quicktime (f, img, kQTFileTypePNG); | ||
| 6631 | } | 6943 | } |
| 6632 | #endif /* MAC_OS */ | 6944 | #endif /* MAC_OS */ |
| 6633 | 6945 | ||
| @@ -7200,7 +7512,9 @@ jpeg_load (f, img) | |||
| 7200 | struct frame *f; | 7512 | struct frame *f; |
| 7201 | struct image *img; | 7513 | struct image *img; |
| 7202 | { | 7514 | { |
| 7203 | #ifdef MAC_OSX | 7515 | #if USE_MAC_IMAGE_IO |
| 7516 | return image_load_image_io (f, img, kUTTypeJPEG); | ||
| 7517 | #elif defined (MAC_OSX) | ||
| 7204 | return image_load_quartz2d (f, img, 0); | 7518 | return image_load_quartz2d (f, img, 0); |
| 7205 | #else | 7519 | #else |
| 7206 | return image_load_quicktime (f, img, kQTFileTypeJPEG); | 7520 | return image_load_quicktime (f, img, kQTFileTypeJPEG); |
| @@ -7625,7 +7939,11 @@ tiff_load (f, img) | |||
| 7625 | struct frame *f; | 7939 | struct frame *f; |
| 7626 | struct image *img; | 7940 | struct image *img; |
| 7627 | { | 7941 | { |
| 7942 | #if USE_MAC_IMAGE_IO | ||
| 7943 | return image_load_image_io (f, img, kUTTypeTIFF); | ||
| 7944 | #else | ||
| 7628 | return image_load_quicktime (f, img, kQTFileTypeTIFF); | 7945 | return image_load_quicktime (f, img, kQTFileTypeTIFF); |
| 7946 | #endif | ||
| 7629 | } | 7947 | } |
| 7630 | #endif /* MAC_OS */ | 7948 | #endif /* MAC_OS */ |
| 7631 | 7949 | ||
| @@ -8061,6 +8379,9 @@ gif_load (f, img) | |||
| 8061 | struct frame *f; | 8379 | struct frame *f; |
| 8062 | struct image *img; | 8380 | struct image *img; |
| 8063 | { | 8381 | { |
| 8382 | #if USE_MAC_IMAGE_IO | ||
| 8383 | return image_load_image_io (f, img, kUTTypeGIF); | ||
| 8384 | #else /* !USE_MAC_IMAGE_IO */ | ||
| 8064 | Lisp_Object specified_file, file; | 8385 | Lisp_Object specified_file, file; |
| 8065 | Lisp_Object specified_data; | 8386 | Lisp_Object specified_data; |
| 8066 | OSErr err; | 8387 | OSErr err; |
| @@ -8189,8 +8510,8 @@ gif_load (f, img) | |||
| 8189 | time_scale = GetMediaTimeScale (media); | 8510 | time_scale = GetMediaTimeScale (media); |
| 8190 | 8511 | ||
| 8191 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | 8512 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); |
| 8192 | if (!STRINGP (specified_bg) || | 8513 | if (!STRINGP (specified_bg) |
| 8193 | !mac_defined_color (f, SDATA (specified_bg), &color, 0)) | 8514 | || !mac_defined_color (f, SDATA (specified_bg), &color, 0)) |
| 8194 | { | 8515 | { |
| 8195 | color.pixel = FRAME_BACKGROUND_PIXEL (f); | 8516 | color.pixel = FRAME_BACKGROUND_PIXEL (f); |
| 8196 | color.red = RED16_FROM_ULONG (color.pixel); | 8517 | color.red = RED16_FROM_ULONG (color.pixel); |
| @@ -8259,6 +8580,7 @@ gif_load (f, img) | |||
| 8259 | if (dh) | 8580 | if (dh) |
| 8260 | DisposeHandle (dh); | 8581 | DisposeHandle (dh); |
| 8261 | return 0; | 8582 | return 0; |
| 8583 | #endif /* !USE_MAC_IMAGE_IO */ | ||
| 8262 | } | 8584 | } |
| 8263 | #endif /* MAC_OS */ | 8585 | #endif /* MAC_OS */ |
| 8264 | 8586 | ||
| @@ -9264,9 +9586,6 @@ meaning don't clear the cache. */); | |||
| 9264 | void | 9586 | void |
| 9265 | init_image () | 9587 | init_image () |
| 9266 | { | 9588 | { |
| 9267 | #if defined (MAC_OSX) && TARGET_API_MAC_CARBON | ||
| 9268 | init_image_func_pointer (); | ||
| 9269 | #endif | ||
| 9270 | } | 9589 | } |
| 9271 | 9590 | ||
| 9272 | /* arch-tag: 123c2a5e-14a8-4c53-ab95-af47d7db49b9 | 9591 | /* arch-tag: 123c2a5e-14a8-4c53-ab95-af47d7db49b9 |