diff options
| author | YAMAMOTO Mitsuharu | 2008-05-02 09:39:01 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2008-05-02 09:39:01 +0000 |
| commit | 2ff0845e68e55250f4c7125757cb3586c9aca052 (patch) | |
| tree | 419600162f26ceeb7c8f567b5eee01f5b55207c1 /src | |
| parent | 61540c1eb6240c180d53d2e500e9d4004101ff1a (diff) | |
| download | emacs-2ff0845e68e55250f4c7125757cb3586c9aca052.tar.gz emacs-2ff0845e68e55250f4c7125757cb3586c9aca052.zip | |
(PIX_MASK_DRAW, PIX_MASK_RETAIN) [USE_MAC_IMAGE_IO]:
New definitions for Image I/O support.
(XGetImage, XPutPixel, XGetPixel, XDestroyImage)
(mac_create_cg_image_from_image, x_create_x_image_and_pixmap)
[USE_MAC_IMAGE_IO]: Add implementations for Image I/O support.
(mac_data_provider_release_data, image_load_image_io)
[USE_MAC_IMAGE_IO]: New functions.
(CGImageCreateWithPNGDataProviderProcType) [MAC_OSX]: Remove typedef.
(MyCGImageCreateWithPNGDataProvider) [MAC_OSX]: Remove variable.
(init_image_func_pointer) [MAC_OSX]: Remove function.
(image_load_quartz2d) [MAC_OSX]: Check availability of
CGImageCreateWithPNGDataProvider at compile time.
Use lowercase `false' for boolean constant.
(png_load, jpeg_load, tiff_load, gif_load) [USE_MAC_IMAGE_IO]:
Use image_load_image_io.
(png_load) [!USE_MAC_IMAGE_IO && MAC_OSX]:
Don't check MyCGImageCreateWithPNGDataProvider.
(init_image) [MAC_OSX && TARGET_API_MAC_CARBON]:
Don't call init_image_func_pointer.
Diffstat (limited to 'src')
| -rw-r--r-- | src/image.c | 395 |
1 files changed, 355 insertions, 40 deletions
diff --git a/src/image.c b/src/image.c index 16515852642..eb1cae853f1 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 */ |
| @@ -2280,7 +2360,9 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) | |||
| 2280 | return 0; | 2360 | return 0; |
| 2281 | } | 2361 | } |
| 2282 | 2362 | ||
| 2363 | #if !USE_MAC_IMAGE_IO | ||
| 2283 | LockPixels (GetGWorldPixMap (*pixmap)); | 2364 | LockPixels (GetGWorldPixMap (*pixmap)); |
| 2365 | #endif | ||
| 2284 | *ximg = *pixmap; | 2366 | *ximg = *pixmap; |
| 2285 | return 1; | 2367 | return 1; |
| 2286 | 2368 | ||
| @@ -2429,6 +2511,252 @@ slurp_file (file, size) | |||
| 2429 | MAC Image Load Functions | 2511 | MAC Image Load Functions |
| 2430 | ***********************************************************************/ | 2512 | ***********************************************************************/ |
| 2431 | 2513 | ||
| 2514 | #if USE_MAC_IMAGE_IO | ||
| 2515 | static int | ||
| 2516 | image_load_image_io (f, img, type) | ||
| 2517 | struct frame *f; | ||
| 2518 | struct image *img; | ||
| 2519 | CFStringRef type; | ||
| 2520 | { | ||
| 2521 | CFDictionaryRef options, src_props = NULL, props = NULL; | ||
| 2522 | CFStringRef keys[2]; | ||
| 2523 | CFTypeRef values[2]; | ||
| 2524 | Lisp_Object specified_file, specified_data; | ||
| 2525 | CGImageSourceRef source = NULL; | ||
| 2526 | size_t count; | ||
| 2527 | CGImageRef image = NULL; | ||
| 2528 | int loop_count = -1; | ||
| 2529 | double delay_time = -1.0; | ||
| 2530 | int width, height; | ||
| 2531 | XImagePtr ximg = NULL; | ||
| 2532 | CGContextRef context; | ||
| 2533 | CGRect rectangle; | ||
| 2534 | int has_alpha_p, gif_p; | ||
| 2535 | |||
| 2536 | gif_p = UTTypeEqual (type, kUTTypeGIF); | ||
| 2537 | |||
| 2538 | keys[0] = kCGImageSourceTypeIdentifierHint; | ||
| 2539 | values[0] = (CFTypeRef) type; | ||
| 2540 | keys[1] = kCGImageSourceShouldCache; | ||
| 2541 | values[1] = (CFTypeRef) kCFBooleanFalse; | ||
| 2542 | options = CFDictionaryCreate (NULL, (const void **) keys, | ||
| 2543 | (const void **) values, | ||
| 2544 | sizeof (keys) / sizeof (keys[0]), | ||
| 2545 | &kCFTypeDictionaryKeyCallBacks, | ||
| 2546 | &kCFTypeDictionaryValueCallBacks); | ||
| 2547 | if (options == NULL) | ||
| 2548 | { | ||
| 2549 | image_error ("Error creating options for image `%s'", img->spec, Qnil); | ||
| 2550 | return 0; | ||
| 2551 | } | ||
| 2552 | |||
| 2553 | /* Open the file. */ | ||
| 2554 | specified_file = image_spec_value (img->spec, QCfile, NULL); | ||
| 2555 | specified_data = image_spec_value (img->spec, QCdata, NULL); | ||
| 2556 | |||
| 2557 | if (NILP (specified_data)) | ||
| 2558 | { | ||
| 2559 | Lisp_Object file; | ||
| 2560 | CFStringRef path; | ||
| 2561 | CFURLRef url; | ||
| 2562 | |||
| 2563 | file = x_find_image_file (specified_file); | ||
| 2564 | if (!STRINGP (file)) | ||
| 2565 | { | ||
| 2566 | image_error ("Cannot find image file `%s'", specified_file, Qnil); | ||
| 2567 | return 0; | ||
| 2568 | } | ||
| 2569 | path = cfstring_create_with_utf8_cstring (SDATA (file)); | ||
| 2570 | if (path) | ||
| 2571 | { | ||
| 2572 | url = CFURLCreateWithFileSystemPath (NULL, path, | ||
| 2573 | kCFURLPOSIXPathStyle, 0); | ||
| 2574 | CFRelease (path); | ||
| 2575 | if (url) | ||
| 2576 | { | ||
| 2577 | source = CGImageSourceCreateWithURL (url, NULL); | ||
| 2578 | CFRelease (url); | ||
| 2579 | } | ||
| 2580 | } | ||
| 2581 | } | ||
| 2582 | else | ||
| 2583 | { | ||
| 2584 | CFDataRef data = CFDataCreate (NULL, SDATA (specified_data), | ||
| 2585 | SBYTES (specified_data)); | ||
| 2586 | |||
| 2587 | if (data) | ||
| 2588 | { | ||
| 2589 | source = CGImageSourceCreateWithData (data, options); | ||
| 2590 | CFRelease (data); | ||
| 2591 | } | ||
| 2592 | } | ||
| 2593 | CFRelease (options); | ||
| 2594 | |||
| 2595 | if (source) | ||
| 2596 | { | ||
| 2597 | CFStringRef real_type = CGImageSourceGetType (source); | ||
| 2598 | |||
| 2599 | if (real_type && UTTypeEqual (type, real_type)) | ||
| 2600 | src_props = CGImageSourceCopyProperties (source, NULL); | ||
| 2601 | if (src_props) | ||
| 2602 | { | ||
| 2603 | EMACS_INT ino = 0; | ||
| 2604 | |||
| 2605 | count = CGImageSourceGetCount (source); | ||
| 2606 | if (gif_p) | ||
| 2607 | { | ||
| 2608 | Lisp_Object image = image_spec_value (img->spec, QCindex, NULL); | ||
| 2609 | |||
| 2610 | if (INTEGERP (image)) | ||
| 2611 | ino = XFASTINT (image); | ||
| 2612 | } | ||
| 2613 | if (ino >= 0 && ino < count) | ||
| 2614 | { | ||
| 2615 | props = CGImageSourceCopyPropertiesAtIndex (source, ino, NULL); | ||
| 2616 | if (props) | ||
| 2617 | image = CGImageSourceCreateImageAtIndex (source, ino, NULL); | ||
| 2618 | } | ||
| 2619 | } | ||
| 2620 | CFRelease (source); | ||
| 2621 | } | ||
| 2622 | |||
| 2623 | if (image == NULL) | ||
| 2624 | { | ||
| 2625 | if (src_props) | ||
| 2626 | CFRelease (src_props); | ||
| 2627 | if (props) | ||
| 2628 | CFRelease (props); | ||
| 2629 | image_error ("Error reading image `%s'", img->spec, Qnil); | ||
| 2630 | return 0; | ||
| 2631 | } | ||
| 2632 | else | ||
| 2633 | { | ||
| 2634 | CFBooleanRef boolean; | ||
| 2635 | |||
| 2636 | if (CFDictionaryGetValueIfPresent (props, kCGImagePropertyHasAlpha, | ||
| 2637 | (const void **) &boolean)) | ||
| 2638 | has_alpha_p = CFBooleanGetValue (boolean); | ||
| 2639 | if (gif_p) | ||
| 2640 | { | ||
| 2641 | CFDictionaryRef dict; | ||
| 2642 | CFNumberRef number; | ||
| 2643 | |||
| 2644 | dict = CFDictionaryGetValue (src_props, | ||
| 2645 | kCGImagePropertyGIFDictionary); | ||
| 2646 | if (dict | ||
| 2647 | && CFDictionaryGetValueIfPresent (dict, | ||
| 2648 | kCGImagePropertyGIFLoopCount, | ||
| 2649 | (const void **) &number)) | ||
| 2650 | CFNumberGetValue (number, kCFNumberIntType, &loop_count); | ||
| 2651 | |||
| 2652 | dict = CFDictionaryGetValue (props, kCGImagePropertyGIFDictionary); | ||
| 2653 | if (dict | ||
| 2654 | && CFDictionaryGetValueIfPresent (dict, | ||
| 2655 | kCGImagePropertyGIFDelayTime, | ||
| 2656 | (const void **) &number)) | ||
| 2657 | CFNumberGetValue (number, kCFNumberDoubleType, &delay_time); | ||
| 2658 | } | ||
| 2659 | CFRelease (src_props); | ||
| 2660 | CFRelease (props); | ||
| 2661 | } | ||
| 2662 | |||
| 2663 | width = img->width = CGImageGetWidth (image); | ||
| 2664 | height = img->height = CGImageGetHeight (image); | ||
| 2665 | |||
| 2666 | if (!check_image_size (f, width, height)) | ||
| 2667 | { | ||
| 2668 | CGImageRelease (image); | ||
| 2669 | image_error ("Invalid image size", Qnil, Qnil); | ||
| 2670 | return 0; | ||
| 2671 | } | ||
| 2672 | |||
| 2673 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) | ||
| 2674 | { | ||
| 2675 | CGImageRelease (image); | ||
| 2676 | image_error ("Out of memory (%s)", img->spec, Qnil); | ||
| 2677 | return 0; | ||
| 2678 | } | ||
| 2679 | rectangle = CGRectMake (0, 0, width, height); | ||
| 2680 | |||
| 2681 | context = CGBitmapContextCreate (ximg->data, ximg->width, ximg->height, 8, | ||
| 2682 | ximg->bytes_per_line, | ||
| 2683 | mac_cg_color_space_rgb, | ||
| 2684 | kCGImageAlphaNoneSkipFirst); | ||
| 2685 | if (has_alpha_p) | ||
| 2686 | { | ||
| 2687 | Lisp_Object specified_bg; | ||
| 2688 | XColor color; | ||
| 2689 | |||
| 2690 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | ||
| 2691 | if (!STRINGP (specified_bg) | ||
| 2692 | || !mac_defined_color (f, SDATA (specified_bg), &color, 0)) | ||
| 2693 | { | ||
| 2694 | color.pixel = FRAME_BACKGROUND_PIXEL (f); | ||
| 2695 | color.red = RED16_FROM_ULONG (color.pixel); | ||
| 2696 | color.green = GREEN16_FROM_ULONG (color.pixel); | ||
| 2697 | color.blue = BLUE16_FROM_ULONG (color.pixel); | ||
| 2698 | } | ||
| 2699 | CGContextSetRGBFillColor (context, color.red / 65535.0, | ||
| 2700 | color.green / 65535.0, | ||
| 2701 | color.blue / 65535.0, 1.0); | ||
| 2702 | CGContextFillRect (context, rectangle); | ||
| 2703 | } | ||
| 2704 | CGContextDrawImage (context, rectangle, image); | ||
| 2705 | CGContextRelease (context); | ||
| 2706 | CGImageRelease (image); | ||
| 2707 | |||
| 2708 | /* Save GIF image extension data for `image-extension-data'. | ||
| 2709 | Format is (count IMAGES | ||
| 2710 | 0xff "NETSCAPE2.0" 0x00 DATA_SUB_BLOCK_FOR_LOOP_COUNT | ||
| 2711 | 0xf9 GRAPHIC_CONTROL_EXTENSION_BLOCK). */ | ||
| 2712 | if (gif_p) | ||
| 2713 | { | ||
| 2714 | img->data.lisp_val = Qnil; | ||
| 2715 | if (delay_time >= 0) | ||
| 2716 | { | ||
| 2717 | Lisp_Object gce = make_uninit_string (4); | ||
| 2718 | int centisec = delay_time * 100.0 + 0.5; | ||
| 2719 | |||
| 2720 | /* Fill the delay time field. */ | ||
| 2721 | SSET (gce, 1, centisec & 0xff); | ||
| 2722 | SSET (gce, 2, (centisec >> 8) & 0xff); | ||
| 2723 | /* We don't know about other fields. */ | ||
| 2724 | SSET (gce, 0, 0); | ||
| 2725 | SSET (gce, 3, 0); | ||
| 2726 | img->data.lisp_val = Fcons (make_number (0xf9), | ||
| 2727 | Fcons (gce, | ||
| 2728 | img->data.lisp_val)); | ||
| 2729 | } | ||
| 2730 | if (loop_count >= 0) | ||
| 2731 | { | ||
| 2732 | Lisp_Object data_sub_block = make_uninit_string (3); | ||
| 2733 | |||
| 2734 | SSET (data_sub_block, 0, 0x01); | ||
| 2735 | SSET (data_sub_block, 1, loop_count & 0xff); | ||
| 2736 | SSET (data_sub_block, 2, (loop_count >> 8) & 0xff); | ||
| 2737 | img->data.lisp_val = Fcons (make_number (0), | ||
| 2738 | Fcons (data_sub_block, | ||
| 2739 | img->data.lisp_val)); | ||
| 2740 | img->data.lisp_val = Fcons (make_number (0xff), | ||
| 2741 | Fcons (build_string ("NETSCAPE2.0"), | ||
| 2742 | img->data.lisp_val)); | ||
| 2743 | } | ||
| 2744 | if (count > 1) | ||
| 2745 | img->data.lisp_val = Fcons (Qcount, | ||
| 2746 | Fcons (make_number (count), | ||
| 2747 | img->data.lisp_val)); | ||
| 2748 | } | ||
| 2749 | |||
| 2750 | /* Maybe fill in the background field while we have ximg handy. */ | ||
| 2751 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | ||
| 2752 | IMAGE_BACKGROUND (img, f, ximg); | ||
| 2753 | |||
| 2754 | /* Put the image into the pixmap. */ | ||
| 2755 | x_put_x_image (f, ximg, img->pixmap, width, height); | ||
| 2756 | x_destroy_x_image (ximg); | ||
| 2757 | return 1; | ||
| 2758 | } | ||
| 2759 | #else /* !USE_MAC_IMAGE_IO */ | ||
| 2432 | static int image_load_quicktime P_ ((struct frame *, struct image *img, | 2760 | static int image_load_quicktime P_ ((struct frame *, struct image *img, |
| 2433 | OSType)); | 2761 | OSType)); |
| 2434 | #ifdef MAC_OSX | 2762 | #ifdef MAC_OSX |
| @@ -2641,30 +2969,6 @@ image_load_quicktime (f, img, type) | |||
| 2641 | 2969 | ||
| 2642 | 2970 | ||
| 2643 | #ifdef MAC_OSX | 2971 | #ifdef MAC_OSX |
| 2644 | /* Load a PNG/JPEG image using Quartz 2D decoding routines. | ||
| 2645 | CGImageCreateWithPNGDataProvider is provided after Mac OS X 10.2. | ||
| 2646 | So don't use this function directly but determine at runtime | ||
| 2647 | whether it exists. */ | ||
| 2648 | typedef CGImageRef (*CGImageCreateWithPNGDataProviderProcType) | ||
| 2649 | (CGDataProviderRef, const float [], bool, CGColorRenderingIntent); | ||
| 2650 | static CGImageCreateWithPNGDataProviderProcType MyCGImageCreateWithPNGDataProvider; | ||
| 2651 | |||
| 2652 | |||
| 2653 | static void | ||
| 2654 | init_image_func_pointer () | ||
| 2655 | { | ||
| 2656 | if (NSIsSymbolNameDefined ("_CGImageCreateWithPNGDataProvider")) | ||
| 2657 | { | ||
| 2658 | MyCGImageCreateWithPNGDataProvider | ||
| 2659 | = (CGImageCreateWithPNGDataProviderProcType) | ||
| 2660 | NSAddressOfSymbol (NSLookupAndBindSymbol | ||
| 2661 | ("_CGImageCreateWithPNGDataProvider")); | ||
| 2662 | } | ||
| 2663 | else | ||
| 2664 | MyCGImageCreateWithPNGDataProvider = NULL; | ||
| 2665 | } | ||
| 2666 | |||
| 2667 | |||
| 2668 | static int | 2972 | static int |
| 2669 | image_load_quartz2d (f, img, png_p) | 2973 | image_load_quartz2d (f, img, png_p) |
| 2670 | struct frame *f; | 2974 | struct frame *f; |
| @@ -2712,11 +3016,13 @@ image_load_quartz2d (f, img, png_p) | |||
| 2712 | source = CGDataProviderCreateWithData (NULL, SDATA (specified_data), | 3016 | source = CGDataProviderCreateWithData (NULL, SDATA (specified_data), |
| 2713 | SBYTES (specified_data), NULL); | 3017 | SBYTES (specified_data), NULL); |
| 2714 | 3018 | ||
| 3019 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 | ||
| 2715 | if (png_p) | 3020 | if (png_p) |
| 2716 | image = (*MyCGImageCreateWithPNGDataProvider) (source, NULL, FALSE, | 3021 | image = CGImageCreateWithPNGDataProvider (source, NULL, false, |
| 2717 | kCGRenderingIntentDefault); | 3022 | kCGRenderingIntentDefault); |
| 2718 | else | 3023 | else |
| 2719 | image = CGImageCreateWithJPEGDataProvider (source, NULL, FALSE, | 3024 | #endif |
| 3025 | image = CGImageCreateWithJPEGDataProvider (source, NULL, false, | ||
| 2720 | kCGRenderingIntentDefault); | 3026 | kCGRenderingIntentDefault); |
| 2721 | 3027 | ||
| 2722 | CGDataProviderRelease (source); | 3028 | CGDataProviderRelease (source); |
| @@ -2780,6 +3086,7 @@ image_load_quartz2d (f, img, png_p) | |||
| 2780 | return 1; | 3086 | return 1; |
| 2781 | } | 3087 | } |
| 2782 | #endif | 3088 | #endif |
| 3089 | #endif /* !USE_MAC_IMAGE_IO */ | ||
| 2783 | 3090 | ||
| 2784 | #endif /* MAC_OS */ | 3091 | #endif /* MAC_OS */ |
| 2785 | 3092 | ||
| @@ -4250,8 +4557,8 @@ xpm_scan (s, end, beg, len) | |||
| 4250 | if (isalpha (c) || c == '_' || c == '-' || c == '+') | 4557 | if (isalpha (c) || c == '_' || c == '-' || c == '+') |
| 4251 | { | 4558 | { |
| 4252 | *beg = *s - 1; | 4559 | *beg = *s - 1; |
| 4253 | while (*s < end && | 4560 | while (*s < end |
| 4254 | (c = **s, isalnum (c) || c == '_' || c == '-' || c == '+')) | 4561 | && (c = **s, isalnum (c) || c == '_' || c == '-' || c == '+')) |
| 4255 | ++*s; | 4562 | ++*s; |
| 4256 | *len = *s - *beg; | 4563 | *len = *s - *beg; |
| 4257 | return XPM_TK_IDENT; | 4564 | return XPM_TK_IDENT; |
| @@ -6597,12 +6904,13 @@ png_load (f, img) | |||
| 6597 | struct frame *f; | 6904 | struct frame *f; |
| 6598 | struct image *img; | 6905 | struct image *img; |
| 6599 | { | 6906 | { |
| 6600 | #ifdef MAC_OSX | 6907 | #if USE_MAC_IMAGE_IO |
| 6601 | if (MyCGImageCreateWithPNGDataProvider) | 6908 | return image_load_image_io (f, img, kUTTypePNG); |
| 6602 | return image_load_quartz2d (f, img, 1); | 6909 | #elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 |
| 6603 | else | 6910 | return image_load_quartz2d (f, img, 1); |
| 6911 | #else | ||
| 6912 | return image_load_quicktime (f, img, kQTFileTypePNG); | ||
| 6604 | #endif | 6913 | #endif |
| 6605 | return image_load_quicktime (f, img, kQTFileTypePNG); | ||
| 6606 | } | 6914 | } |
| 6607 | #endif /* MAC_OS */ | 6915 | #endif /* MAC_OS */ |
| 6608 | 6916 | ||
| @@ -7175,7 +7483,9 @@ jpeg_load (f, img) | |||
| 7175 | struct frame *f; | 7483 | struct frame *f; |
| 7176 | struct image *img; | 7484 | struct image *img; |
| 7177 | { | 7485 | { |
| 7178 | #ifdef MAC_OSX | 7486 | #if USE_MAC_IMAGE_IO |
| 7487 | return image_load_image_io (f, img, kUTTypeJPEG); | ||
| 7488 | #elif defined (MAC_OSX) | ||
| 7179 | return image_load_quartz2d (f, img, 0); | 7489 | return image_load_quartz2d (f, img, 0); |
| 7180 | #else | 7490 | #else |
| 7181 | return image_load_quicktime (f, img, kQTFileTypeJPEG); | 7491 | return image_load_quicktime (f, img, kQTFileTypeJPEG); |
| @@ -7600,7 +7910,11 @@ tiff_load (f, img) | |||
| 7600 | struct frame *f; | 7910 | struct frame *f; |
| 7601 | struct image *img; | 7911 | struct image *img; |
| 7602 | { | 7912 | { |
| 7913 | #if USE_MAC_IMAGE_IO | ||
| 7914 | return image_load_image_io (f, img, kUTTypeTIFF); | ||
| 7915 | #else | ||
| 7603 | return image_load_quicktime (f, img, kQTFileTypeTIFF); | 7916 | return image_load_quicktime (f, img, kQTFileTypeTIFF); |
| 7917 | #endif | ||
| 7604 | } | 7918 | } |
| 7605 | #endif /* MAC_OS */ | 7919 | #endif /* MAC_OS */ |
| 7606 | 7920 | ||
| @@ -8036,6 +8350,9 @@ gif_load (f, img) | |||
| 8036 | struct frame *f; | 8350 | struct frame *f; |
| 8037 | struct image *img; | 8351 | struct image *img; |
| 8038 | { | 8352 | { |
| 8353 | #if USE_MAC_IMAGE_IO | ||
| 8354 | return image_load_image_io (f, img, kUTTypeGIF); | ||
| 8355 | #else /* !USE_MAC_IMAGE_IO */ | ||
| 8039 | Lisp_Object specified_file, file; | 8356 | Lisp_Object specified_file, file; |
| 8040 | Lisp_Object specified_data; | 8357 | Lisp_Object specified_data; |
| 8041 | OSErr err; | 8358 | OSErr err; |
| @@ -8164,8 +8481,8 @@ gif_load (f, img) | |||
| 8164 | time_scale = GetMediaTimeScale (media); | 8481 | time_scale = GetMediaTimeScale (media); |
| 8165 | 8482 | ||
| 8166 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | 8483 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); |
| 8167 | if (!STRINGP (specified_bg) || | 8484 | if (!STRINGP (specified_bg) |
| 8168 | !mac_defined_color (f, SDATA (specified_bg), &color, 0)) | 8485 | || !mac_defined_color (f, SDATA (specified_bg), &color, 0)) |
| 8169 | { | 8486 | { |
| 8170 | color.pixel = FRAME_BACKGROUND_PIXEL (f); | 8487 | color.pixel = FRAME_BACKGROUND_PIXEL (f); |
| 8171 | color.red = RED16_FROM_ULONG (color.pixel); | 8488 | color.red = RED16_FROM_ULONG (color.pixel); |
| @@ -8234,6 +8551,7 @@ gif_load (f, img) | |||
| 8234 | if (dh) | 8551 | if (dh) |
| 8235 | DisposeHandle (dh); | 8552 | DisposeHandle (dh); |
| 8236 | return 0; | 8553 | return 0; |
| 8554 | #endif /* !USE_MAC_IMAGE_IO */ | ||
| 8237 | } | 8555 | } |
| 8238 | #endif /* MAC_OS */ | 8556 | #endif /* MAC_OS */ |
| 8239 | 8557 | ||
| @@ -8807,9 +9125,6 @@ meaning don't clear the cache. */); | |||
| 8807 | void | 9125 | void |
| 8808 | init_image () | 9126 | init_image () |
| 8809 | { | 9127 | { |
| 8810 | #if defined (MAC_OSX) && TARGET_API_MAC_CARBON | ||
| 8811 | init_image_func_pointer (); | ||
| 8812 | #endif | ||
| 8813 | } | 9128 | } |
| 8814 | 9129 | ||
| 8815 | /* arch-tag: 123c2a5e-14a8-4c53-ab95-af47d7db49b9 | 9130 | /* arch-tag: 123c2a5e-14a8-4c53-ab95-af47d7db49b9 |