diff options
| author | Stefan Monnier | 2011-03-21 12:42:16 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2011-03-21 12:42:16 -0400 |
| commit | cafdcef32d55cbb44389d7e322e7f973cbb72dfd (patch) | |
| tree | 7ee0c41ea8a589650ce6f4311fb10e61a63807b9 /src/image.c | |
| parent | a08a25d7aaf251aa18f2ef747be53734bc55cae9 (diff) | |
| parent | 4e05e67e4cd0bc1b0a4ef3176a4d0d91c6b3738e (diff) | |
| download | emacs-cafdcef32d55cbb44389d7e322e7f973cbb72dfd.tar.gz emacs-cafdcef32d55cbb44389d7e322e7f973cbb72dfd.zip | |
Merge from trunk
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/src/image.c b/src/image.c index 73a45633f3b..91308c540b5 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -550,10 +550,6 @@ x_create_bitmap_mask (struct frame *f, int id) | |||
| 550 | Image types | 550 | Image types |
| 551 | ***********************************************************************/ | 551 | ***********************************************************************/ |
| 552 | 552 | ||
| 553 | /* Value is the number of elements of vector VECTOR. */ | ||
| 554 | |||
| 555 | #define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR)) | ||
| 556 | |||
| 557 | /* List of supported image types. Use define_image_type to add new | 553 | /* List of supported image types. Use define_image_type to add new |
| 558 | types. Use lookup_image_type to find a type for a given symbol. */ | 554 | types. Use lookup_image_type to find a type for a given symbol. */ |
| 559 | 555 | ||
| @@ -1139,7 +1135,7 @@ static RGB_PIXEL_COLOR | |||
| 1139 | four_corners_best (XImagePtr_or_DC ximg, int *corners, | 1135 | four_corners_best (XImagePtr_or_DC ximg, int *corners, |
| 1140 | unsigned long width, unsigned long height) | 1136 | unsigned long width, unsigned long height) |
| 1141 | { | 1137 | { |
| 1142 | RGB_PIXEL_COLOR corner_pixels[4], best; | 1138 | RGB_PIXEL_COLOR corner_pixels[4], best IF_LINT (= 0); |
| 1143 | int i, best_count; | 1139 | int i, best_count; |
| 1144 | 1140 | ||
| 1145 | if (corners && corners[BOT_CORNER] >= 0) | 1141 | if (corners && corners[BOT_CORNER] >= 0) |
| @@ -1491,7 +1487,7 @@ free_image_cache (struct frame *f) | |||
| 1491 | If image-cache-eviction-delay is non-nil, this frees images in the cache | 1487 | If image-cache-eviction-delay is non-nil, this frees images in the cache |
| 1492 | which weren't displayed for at least that many seconds. */ | 1488 | which weren't displayed for at least that many seconds. */ |
| 1493 | 1489 | ||
| 1494 | void | 1490 | static void |
| 1495 | clear_image_cache (struct frame *f, Lisp_Object filter) | 1491 | clear_image_cache (struct frame *f, Lisp_Object filter) |
| 1496 | { | 1492 | { |
| 1497 | struct image_cache *c = FRAME_IMAGE_CACHE (f); | 1493 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| @@ -1559,9 +1555,9 @@ clear_image_cache (struct frame *f, Lisp_Object filter) | |||
| 1559 | 1555 | ||
| 1560 | FOR_EACH_FRAME (tail, frame) | 1556 | FOR_EACH_FRAME (tail, frame) |
| 1561 | { | 1557 | { |
| 1562 | struct frame *f = XFRAME (frame); | 1558 | struct frame *fr = XFRAME (frame); |
| 1563 | if (FRAME_IMAGE_CACHE (f) == c) | 1559 | if (FRAME_IMAGE_CACHE (fr) == c) |
| 1564 | clear_current_matrices (f); | 1560 | clear_current_matrices (fr); |
| 1565 | } | 1561 | } |
| 1566 | 1562 | ||
| 1567 | ++windows_or_buffers_changed; | 1563 | ++windows_or_buffers_changed; |
| @@ -2653,11 +2649,11 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e | |||
| 2653 | 2649 | ||
| 2654 | if (LA1 == XBM_TK_NUMBER) | 2650 | if (LA1 == XBM_TK_NUMBER) |
| 2655 | { | 2651 | { |
| 2656 | char *p = strrchr (buffer, '_'); | 2652 | char *q = strrchr (buffer, '_'); |
| 2657 | p = p ? p + 1 : buffer; | 2653 | q = q ? q + 1 : buffer; |
| 2658 | if (strcmp (p, "width") == 0) | 2654 | if (strcmp (q, "width") == 0) |
| 2659 | *width = value; | 2655 | *width = value; |
| 2660 | else if (strcmp (p, "height") == 0) | 2656 | else if (strcmp (q, "height") == 0) |
| 2661 | *height = value; | 2657 | *height = value; |
| 2662 | } | 2658 | } |
| 2663 | expect (XBM_TK_NUMBER); | 2659 | expect (XBM_TK_NUMBER); |
| @@ -3427,11 +3423,12 @@ xpm_load (struct frame *f, struct image *img) | |||
| 3427 | { | 3423 | { |
| 3428 | Lisp_Object name; | 3424 | Lisp_Object name; |
| 3429 | Lisp_Object color; | 3425 | Lisp_Object color; |
| 3426 | char *empty_string = (char *) ""; | ||
| 3430 | 3427 | ||
| 3431 | if (!CONSP (XCAR (tail))) | 3428 | if (!CONSP (XCAR (tail))) |
| 3432 | { | 3429 | { |
| 3433 | xpm_syms[i].name = ""; | 3430 | xpm_syms[i].name = empty_string; |
| 3434 | xpm_syms[i].value = ""; | 3431 | xpm_syms[i].value = empty_string; |
| 3435 | continue; | 3432 | continue; |
| 3436 | } | 3433 | } |
| 3437 | name = XCAR (XCAR (tail)); | 3434 | name = XCAR (XCAR (tail)); |
| @@ -3442,14 +3439,14 @@ xpm_load (struct frame *f, struct image *img) | |||
| 3442 | strcpy (xpm_syms[i].name, SSDATA (name)); | 3439 | strcpy (xpm_syms[i].name, SSDATA (name)); |
| 3443 | } | 3440 | } |
| 3444 | else | 3441 | else |
| 3445 | xpm_syms[i].name = ""; | 3442 | xpm_syms[i].name = empty_string; |
| 3446 | if (STRINGP (color)) | 3443 | if (STRINGP (color)) |
| 3447 | { | 3444 | { |
| 3448 | xpm_syms[i].value = (char *) alloca (SCHARS (color) + 1); | 3445 | xpm_syms[i].value = (char *) alloca (SCHARS (color) + 1); |
| 3449 | strcpy (xpm_syms[i].value, SSDATA (color)); | 3446 | strcpy (xpm_syms[i].value, SSDATA (color)); |
| 3450 | } | 3447 | } |
| 3451 | else | 3448 | else |
| 3452 | xpm_syms[i].value = ""; | 3449 | xpm_syms[i].value = empty_string; |
| 3453 | } | 3450 | } |
| 3454 | } | 3451 | } |
| 3455 | 3452 | ||
| @@ -4605,14 +4602,14 @@ x_detect_edges (struct frame *f, struct image *img, int *matrix, int color_adjus | |||
| 4605 | 4602 | ||
| 4606 | for (x = 1; x < img->width - 1; ++x, ++p) | 4603 | for (x = 1; x < img->width - 1; ++x, ++p) |
| 4607 | { | 4604 | { |
| 4608 | int r, g, b, y1, x1; | 4605 | int r, g, b, yy, xx; |
| 4609 | 4606 | ||
| 4610 | r = g = b = i = 0; | 4607 | r = g = b = i = 0; |
| 4611 | for (y1 = y - 1; y1 < y + 2; ++y1) | 4608 | for (yy = y - 1; yy < y + 2; ++yy) |
| 4612 | for (x1 = x - 1; x1 < x + 2; ++x1, ++i) | 4609 | for (xx = x - 1; xx < x + 2; ++xx, ++i) |
| 4613 | if (matrix[i]) | 4610 | if (matrix[i]) |
| 4614 | { | 4611 | { |
| 4615 | XColor *t = COLOR (colors, x1, y1); | 4612 | XColor *t = COLOR (colors, xx, yy); |
| 4616 | r += matrix[i] * t->red; | 4613 | r += matrix[i] * t->red; |
| 4617 | g += matrix[i] * t->green; | 4614 | g += matrix[i] * t->green; |
| 4618 | b += matrix[i] * t->blue; | 4615 | b += matrix[i] * t->blue; |
| @@ -4688,7 +4685,7 @@ x_edge_detection (struct frame *f, struct image *img, Lisp_Object matrix, | |||
| 4688 | color_adjust = make_number (0xffff / 2); | 4685 | color_adjust = make_number (0xffff / 2); |
| 4689 | 4686 | ||
| 4690 | if (i == 9 && NUMBERP (color_adjust)) | 4687 | if (i == 9 && NUMBERP (color_adjust)) |
| 4691 | x_detect_edges (f, img, trans, (int) XFLOATINT (color_adjust)); | 4688 | x_detect_edges (f, img, trans, XFLOATINT (color_adjust)); |
| 4692 | } | 4689 | } |
| 4693 | 4690 | ||
| 4694 | 4691 | ||
| @@ -5531,6 +5528,7 @@ init_png_functions (Lisp_Object libraries) | |||
| 5531 | /* Error and warning handlers installed when the PNG library | 5528 | /* Error and warning handlers installed when the PNG library |
| 5532 | is initialized. */ | 5529 | is initialized. */ |
| 5533 | 5530 | ||
| 5531 | static void my_png_error (png_struct *, const char *) NO_RETURN; | ||
| 5534 | static void | 5532 | static void |
| 5535 | my_png_error (png_struct *png_ptr, const char *msg) | 5533 | my_png_error (png_struct *png_ptr, const char *msg) |
| 5536 | { | 5534 | { |
| @@ -6030,7 +6028,6 @@ jpeg_image_p (Lisp_Object object) | |||
| 6030 | /* Work around a warning about HAVE_STDLIB_H being redefined in | 6028 | /* Work around a warning about HAVE_STDLIB_H being redefined in |
| 6031 | jconfig.h. */ | 6029 | jconfig.h. */ |
| 6032 | #ifdef HAVE_STDLIB_H | 6030 | #ifdef HAVE_STDLIB_H |
| 6033 | #define HAVE_STDLIB_H_1 | ||
| 6034 | #undef HAVE_STDLIB_H | 6031 | #undef HAVE_STDLIB_H |
| 6035 | #endif /* HAVE_STLIB_H */ | 6032 | #endif /* HAVE_STLIB_H */ |
| 6036 | 6033 | ||
| @@ -6106,6 +6103,7 @@ struct my_jpeg_error_mgr | |||
| 6106 | }; | 6103 | }; |
| 6107 | 6104 | ||
| 6108 | 6105 | ||
| 6106 | static void my_error_exit (j_common_ptr) NO_RETURN; | ||
| 6109 | static void | 6107 | static void |
| 6110 | my_error_exit (j_common_ptr cinfo) | 6108 | my_error_exit (j_common_ptr cinfo) |
| 6111 | { | 6109 | { |
| @@ -6366,10 +6364,10 @@ jpeg_load (struct frame *f, struct image *img) | |||
| 6366 | if (rc == 1) | 6364 | if (rc == 1) |
| 6367 | { | 6365 | { |
| 6368 | /* Called from my_error_exit. Display a JPEG error. */ | 6366 | /* Called from my_error_exit. Display a JPEG error. */ |
| 6369 | char buffer[JMSG_LENGTH_MAX]; | 6367 | char buf[JMSG_LENGTH_MAX]; |
| 6370 | cinfo.err->format_message ((j_common_ptr) &cinfo, buffer); | 6368 | cinfo.err->format_message ((j_common_ptr) &cinfo, buf); |
| 6371 | image_error ("Error reading JPEG image `%s': %s", img->spec, | 6369 | image_error ("Error reading JPEG image `%s': %s", img->spec, |
| 6372 | build_string (buffer)); | 6370 | build_string (buf)); |
| 6373 | } | 6371 | } |
| 6374 | 6372 | ||
| 6375 | /* Close the input file and destroy the JPEG object. */ | 6373 | /* Close the input file and destroy the JPEG object. */ |
| @@ -7105,7 +7103,7 @@ gif_load (struct frame *f, struct image *img) | |||
| 7105 | Lisp_Object file, specified_file; | 7103 | Lisp_Object file, specified_file; |
| 7106 | Lisp_Object specified_data; | 7104 | Lisp_Object specified_data; |
| 7107 | int rc, width, height, x, y, i; | 7105 | int rc, width, height, x, y, i; |
| 7108 | boolean transparent_p; | 7106 | boolean transparent_p = 0; |
| 7109 | XImagePtr ximg; | 7107 | XImagePtr ximg; |
| 7110 | ColorMapObject *gif_color_map; | 7108 | ColorMapObject *gif_color_map; |
| 7111 | unsigned long pixel_colors[256]; | 7109 | unsigned long pixel_colors[256]; |
| @@ -7114,7 +7112,7 @@ gif_load (struct frame *f, struct image *img) | |||
| 7114 | int ino, image_height, image_width; | 7112 | int ino, image_height, image_width; |
| 7115 | gif_memory_source memsrc; | 7113 | gif_memory_source memsrc; |
| 7116 | unsigned char *raster; | 7114 | unsigned char *raster; |
| 7117 | unsigned int transparency_color_index; | 7115 | unsigned int transparency_color_index IF_LINT (= 0); |
| 7118 | 7116 | ||
| 7119 | specified_file = image_spec_value (img->spec, QCfile, NULL); | 7117 | specified_file = image_spec_value (img->spec, QCfile, NULL); |
| 7120 | specified_data = image_spec_value (img->spec, QCdata, NULL); | 7118 | specified_data = image_spec_value (img->spec, QCdata, NULL); |
| @@ -7129,7 +7127,7 @@ gif_load (struct frame *f, struct image *img) | |||
| 7129 | } | 7127 | } |
| 7130 | 7128 | ||
| 7131 | /* Open the GIF file. */ | 7129 | /* Open the GIF file. */ |
| 7132 | gif = fn_DGifOpenFileName (SDATA (file)); | 7130 | gif = fn_DGifOpenFileName (SSDATA (file)); |
| 7133 | if (gif == NULL) | 7131 | if (gif == NULL) |
| 7134 | { | 7132 | { |
| 7135 | image_error ("Cannot open `%s'", file, Qnil); | 7133 | image_error ("Cannot open `%s'", file, Qnil); |
| @@ -7302,9 +7300,9 @@ gif_load (struct frame *f, struct image *img) | |||
| 7302 | 7300 | ||
| 7303 | for (x = 0; x < image_width; x++) | 7301 | for (x = 0; x < image_width; x++) |
| 7304 | { | 7302 | { |
| 7305 | int i = raster[(y * image_width) + x]; | 7303 | int c = raster[(y * image_width) + x]; |
| 7306 | XPutPixel (ximg, x + img->corners[LEFT_CORNER], | 7304 | XPutPixel (ximg, x + img->corners[LEFT_CORNER], |
| 7307 | row + img->corners[TOP_CORNER], pixel_colors[i]); | 7305 | row + img->corners[TOP_CORNER], pixel_colors[c]); |
| 7308 | } | 7306 | } |
| 7309 | 7307 | ||
| 7310 | row += interlace_increment[pass]; | 7308 | row += interlace_increment[pass]; |
| @@ -7315,9 +7313,9 @@ gif_load (struct frame *f, struct image *img) | |||
| 7315 | for (y = 0; y < image_height; ++y) | 7313 | for (y = 0; y < image_height; ++y) |
| 7316 | for (x = 0; x < image_width; ++x) | 7314 | for (x = 0; x < image_width; ++x) |
| 7317 | { | 7315 | { |
| 7318 | int i = raster[y * image_width + x]; | 7316 | int c = raster[y * image_width + x]; |
| 7319 | XPutPixel (ximg, x + img->corners[LEFT_CORNER], | 7317 | XPutPixel (ximg, x + img->corners[LEFT_CORNER], |
| 7320 | y + img->corners[TOP_CORNER], pixel_colors[i]); | 7318 | y + img->corners[TOP_CORNER], pixel_colors[c]); |
| 7321 | } | 7319 | } |
| 7322 | } | 7320 | } |
| 7323 | 7321 | ||