diff options
| author | Jason Rumney | 2001-11-18 21:57:18 +0000 |
|---|---|---|
| committer | Jason Rumney | 2001-11-18 21:57:18 +0000 |
| commit | a05e2bae0da8cc92a36af09b4035c0b898445709 (patch) | |
| tree | f5961a56b5521df365e633bd2f5f91b2289a6545 | |
| parent | 6ff3e5e3cdba7a0b98a5e23f2900089194b303b2 (diff) | |
| download | emacs-a05e2bae0da8cc92a36af09b4035c0b898445709.tar.gz emacs-a05e2bae0da8cc92a36af09b4035c0b898445709.zip | |
(x_set_frame_parameters): Avoid infinite recursion for
some items.
(x_set_internal_border_width): Set frame garbaged when window
doesn't exist yet.
(Fx_create_frame): Accept zero tool_bar_button_relief.
(x_clear_image_1, four_corners_best, image_background)
(image_background_transparent): New functions.
(xpm_format, png_format, jpeg_format, tiff_format, gif_format)
(gs_format): Add `:background' entry.
(lookup_image): Set IMG's background color if specified.
(pbm_load, xbm_load_image, png_load): Set IMG's background field
when appropriate.
(x_clear_image_1): Reset `background_valid' and
`background_transparent_valid' fields.
(x_build_heuristic_mask): Use IMAGE_BACKGROUND instead of
calculating it here. Set IMG's background_transparent field.
(enum xpm_keyword_index): Add XPM_BACKGROUND.
(enum png_keyword_index): Add PNG_BACKGROUND.
(enum jpeg_keyword_index): Add JPEG_BACKGROUND.
(enum tiff_keyword_index): Add TIFF_BACKGROUND.
(enum gif_keyword_index): Add GIF_BACKGROUND.
(enum gs_keyword_index): Add GS_BACKGROUND.
(pbm_load, png_load, jpeg_load, tiff_load, gif_load):
Pre-calculate image background color where necessary.
(x_create_x_image_and_pixmap, xbm_load, gs_load): Use
display info's n_cbits entry for screen depth.
(Fx_show_tip): Remove unused variables `buffer', `top',
`left', `max_width' and `max_height'.
| -rw-r--r-- | src/w32fns.c | 436 |
1 files changed, 321 insertions, 115 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 7a962bf8811..202cebcfb8a 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -820,13 +820,18 @@ x_set_frame_parameters (f, alist) | |||
| 820 | { | 820 | { |
| 821 | register Lisp_Object param_index, old_value; | 821 | register Lisp_Object param_index, old_value; |
| 822 | 822 | ||
| 823 | param_index = Fget (prop, Qx_frame_parameter); | ||
| 824 | old_value = get_frame_param (f, prop); | 823 | old_value = get_frame_param (f, prop); |
| 825 | store_frame_param (f, prop, val); | 824 | |
| 826 | if (NATNUMP (param_index) | 825 | if (NILP (Fequal (val, old_value))) |
| 827 | && (XFASTINT (param_index) | 826 | { |
| 828 | < sizeof (x_frame_parms)/sizeof (x_frame_parms[0]))) | 827 | store_frame_param (f, prop, val); |
| 829 | (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value); | 828 | |
| 829 | param_index = Fget (prop, Qx_frame_parameter); | ||
| 830 | if (NATNUMP (param_index) | ||
| 831 | && (XFASTINT (param_index) | ||
| 832 | < sizeof (x_frame_parms)/sizeof (x_frame_parms[0]))) | ||
| 833 | (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value); | ||
| 834 | } | ||
| 830 | } | 835 | } |
| 831 | } | 836 | } |
| 832 | 837 | ||
| @@ -857,9 +862,11 @@ x_set_frame_parameters (f, alist) | |||
| 857 | { | 862 | { |
| 858 | register Lisp_Object param_index, old_value; | 863 | register Lisp_Object param_index, old_value; |
| 859 | 864 | ||
| 860 | param_index = Fget (prop, Qx_frame_parameter); | ||
| 861 | old_value = get_frame_param (f, prop); | 865 | old_value = get_frame_param (f, prop); |
| 866 | |||
| 862 | store_frame_param (f, prop, val); | 867 | store_frame_param (f, prop, val); |
| 868 | |||
| 869 | param_index = Fget (prop, Qx_frame_parameter); | ||
| 863 | if (NATNUMP (param_index) | 870 | if (NATNUMP (param_index) |
| 864 | && (XFASTINT (param_index) | 871 | && (XFASTINT (param_index) |
| 865 | < sizeof (x_frame_parms)/sizeof (x_frame_parms[0]))) | 872 | < sizeof (x_frame_parms)/sizeof (x_frame_parms[0]))) |
| @@ -2468,6 +2475,8 @@ x_set_internal_border_width (f, arg, oldval) | |||
| 2468 | SET_FRAME_GARBAGED (f); | 2475 | SET_FRAME_GARBAGED (f); |
| 2469 | do_pending_window_change (0); | 2476 | do_pending_window_change (0); |
| 2470 | } | 2477 | } |
| 2478 | else | ||
| 2479 | SET_FRAME_GARBAGED (f); | ||
| 2471 | } | 2480 | } |
| 2472 | 2481 | ||
| 2473 | void | 2482 | void |
| @@ -5414,7 +5423,7 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 5414 | { | 5423 | { |
| 5415 | int margin, relief, bar_height; | 5424 | int margin, relief, bar_height; |
| 5416 | 5425 | ||
| 5417 | relief = (tool_bar_button_relief > 0 | 5426 | relief = (tool_bar_button_relief >= 0 |
| 5418 | ? tool_bar_button_relief | 5427 | ? tool_bar_button_relief |
| 5419 | : DEFAULT_TOOL_BAR_BUTTON_RELIEF); | 5428 | : DEFAULT_TOOL_BAR_BUTTON_RELIEF); |
| 5420 | 5429 | ||
| @@ -8179,16 +8188,162 @@ image_ascent (img, face) | |||
| 8179 | 8188 | ||
| 8180 | 8189 | ||
| 8181 | 8190 | ||
| 8191 | /* Image background colors. */ | ||
| 8192 | |||
| 8193 | static unsigned long | ||
| 8194 | four_corners_best (ximg, width, height) | ||
| 8195 | XImage *ximg; | ||
| 8196 | unsigned long width, height; | ||
| 8197 | { | ||
| 8198 | #if 0 /* TODO: Image support. */ | ||
| 8199 | unsigned long corners[4], best; | ||
| 8200 | int i, best_count; | ||
| 8201 | |||
| 8202 | /* Get the colors at the corners of ximg. */ | ||
| 8203 | corners[0] = XGetPixel (ximg, 0, 0); | ||
| 8204 | corners[1] = XGetPixel (ximg, width - 1, 0); | ||
| 8205 | corners[2] = XGetPixel (ximg, width - 1, height - 1); | ||
| 8206 | corners[3] = XGetPixel (ximg, 0, height - 1); | ||
| 8207 | |||
| 8208 | /* Choose the most frequently found color as background. */ | ||
| 8209 | for (i = best_count = 0; i < 4; ++i) | ||
| 8210 | { | ||
| 8211 | int j, n; | ||
| 8212 | |||
| 8213 | for (j = n = 0; j < 4; ++j) | ||
| 8214 | if (corners[i] == corners[j]) | ||
| 8215 | ++n; | ||
| 8216 | |||
| 8217 | if (n > best_count) | ||
| 8218 | best = corners[i], best_count = n; | ||
| 8219 | } | ||
| 8220 | |||
| 8221 | return best; | ||
| 8222 | #else | ||
| 8223 | return 0; | ||
| 8224 | #endif | ||
| 8225 | } | ||
| 8226 | |||
| 8227 | /* Return the `background' field of IMG. If IMG doesn't have one yet, | ||
| 8228 | it is guessed heuristically. If non-zero, XIMG is an existing XImage | ||
| 8229 | object to use for the heuristic. */ | ||
| 8230 | |||
| 8231 | unsigned long | ||
| 8232 | image_background (img, f, ximg) | ||
| 8233 | struct image *img; | ||
| 8234 | struct frame *f; | ||
| 8235 | XImage *ximg; | ||
| 8236 | { | ||
| 8237 | if (! img->background_valid) | ||
| 8238 | /* IMG doesn't have a background yet, try to guess a reasonable value. */ | ||
| 8239 | { | ||
| 8240 | #if 0 /* TODO: Image support. */ | ||
| 8241 | int free_ximg = !ximg; | ||
| 8242 | |||
| 8243 | if (! ximg) | ||
| 8244 | ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap, | ||
| 8245 | 0, 0, img->width, img->height, ~0, ZPixmap); | ||
| 8246 | |||
| 8247 | img->background = four_corners_best (ximg, img->width, img->height); | ||
| 8248 | |||
| 8249 | if (free_ximg) | ||
| 8250 | XDestroyImage (ximg); | ||
| 8251 | |||
| 8252 | img->background_valid = 1; | ||
| 8253 | #endif | ||
| 8254 | } | ||
| 8255 | |||
| 8256 | return img->background; | ||
| 8257 | } | ||
| 8258 | |||
| 8259 | /* Return the `background_transparent' field of IMG. If IMG doesn't | ||
| 8260 | have one yet, it is guessed heuristically. If non-zero, MASK is an | ||
| 8261 | existing XImage object to use for the heuristic. */ | ||
| 8262 | |||
| 8263 | int | ||
| 8264 | image_background_transparent (img, f, mask) | ||
| 8265 | struct image *img; | ||
| 8266 | struct frame *f; | ||
| 8267 | XImage *mask; | ||
| 8268 | { | ||
| 8269 | if (! img->background_transparent_valid) | ||
| 8270 | /* IMG doesn't have a background yet, try to guess a reasonable value. */ | ||
| 8271 | { | ||
| 8272 | #if 0 /* TODO: Image support. */ | ||
| 8273 | if (img->mask) | ||
| 8274 | { | ||
| 8275 | int free_mask = !mask; | ||
| 8276 | |||
| 8277 | if (! mask) | ||
| 8278 | mask = XGetImage (FRAME_X_DISPLAY (f), img->mask, | ||
| 8279 | 0, 0, img->width, img->height, ~0, ZPixmap); | ||
| 8280 | |||
| 8281 | img->background_transparent | ||
| 8282 | = !four_corners_best (mask, img->width, img->height); | ||
| 8283 | |||
| 8284 | if (free_mask) | ||
| 8285 | XDestroyImage (mask); | ||
| 8286 | } | ||
| 8287 | else | ||
| 8288 | #endif | ||
| 8289 | img->background_transparent = 0; | ||
| 8290 | |||
| 8291 | img->background_transparent_valid = 1; | ||
| 8292 | } | ||
| 8293 | |||
| 8294 | return img->background_transparent; | ||
| 8295 | } | ||
| 8296 | |||
| 8297 | |||
| 8182 | /*********************************************************************** | 8298 | /*********************************************************************** |
| 8183 | Helper functions for X image types | 8299 | Helper functions for X image types |
| 8184 | ***********************************************************************/ | 8300 | ***********************************************************************/ |
| 8185 | 8301 | ||
| 8302 | static void x_clear_image_1 P_ ((struct frame *, struct image *, int, | ||
| 8303 | int, int)); | ||
| 8186 | static void x_clear_image P_ ((struct frame *f, struct image *img)); | 8304 | static void x_clear_image P_ ((struct frame *f, struct image *img)); |
| 8187 | static unsigned long x_alloc_image_color P_ ((struct frame *f, | 8305 | static unsigned long x_alloc_image_color P_ ((struct frame *f, |
| 8188 | struct image *img, | 8306 | struct image *img, |
| 8189 | Lisp_Object color_name, | 8307 | Lisp_Object color_name, |
| 8190 | unsigned long dflt)); | 8308 | unsigned long dflt)); |
| 8191 | 8309 | ||
| 8310 | |||
| 8311 | /* Clear X resources of image IMG on frame F. PIXMAP_P non-zero means | ||
| 8312 | free the pixmap if any. MASK_P non-zero means clear the mask | ||
| 8313 | pixmap if any. COLORS_P non-zero means free colors allocated for | ||
| 8314 | the image, if any. */ | ||
| 8315 | |||
| 8316 | static void | ||
| 8317 | x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p) | ||
| 8318 | struct frame *f; | ||
| 8319 | struct image *img; | ||
| 8320 | int pixmap_p, mask_p, colors_p; | ||
| 8321 | { | ||
| 8322 | #if 0 | ||
| 8323 | if (pixmap_p && img->pixmap) | ||
| 8324 | { | ||
| 8325 | XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap); | ||
| 8326 | img->pixmap = None; | ||
| 8327 | img->background_valid = 0; | ||
| 8328 | } | ||
| 8329 | |||
| 8330 | if (mask_p && img->mask) | ||
| 8331 | { | ||
| 8332 | XFreePixmap (FRAME_X_DISPLAY (f), img->mask); | ||
| 8333 | img->mask = None; | ||
| 8334 | img->background_transparent_valid = 0; | ||
| 8335 | } | ||
| 8336 | |||
| 8337 | if (colors_p && img->ncolors) | ||
| 8338 | { | ||
| 8339 | x_free_colors (f, img->colors, img->ncolors); | ||
| 8340 | xfree (img->colors); | ||
| 8341 | img->colors = NULL; | ||
| 8342 | img->ncolors = 0; | ||
| 8343 | } | ||
| 8344 | #endif | ||
| 8345 | } | ||
| 8346 | |||
| 8192 | /* Free X resources of image IMG which is used on frame F. */ | 8347 | /* Free X resources of image IMG which is used on frame F. */ |
| 8193 | 8348 | ||
| 8194 | static void | 8349 | static void |
| @@ -8527,8 +8682,9 @@ lookup_image (f, spec) | |||
| 8527 | else | 8682 | else |
| 8528 | { | 8683 | { |
| 8529 | /* Handle image type independent image attributes | 8684 | /* Handle image type independent image attributes |
| 8530 | `:ascent PERCENT', `:margin MARGIN', `:relief RELIEF'. */ | 8685 | `:ascent PERCENT', `:margin MARGIN', `:relief RELIEF', |
| 8531 | Lisp_Object ascent, margin, relief; | 8686 | `:background COLOR'. */ |
| 8687 | Lisp_Object ascent, margin, relief, bg; | ||
| 8532 | 8688 | ||
| 8533 | ascent = image_spec_value (spec, QCascent, NULL); | 8689 | ascent = image_spec_value (spec, QCascent, NULL); |
| 8534 | if (INTEGERP (ascent)) | 8690 | if (INTEGERP (ascent)) |
| @@ -8556,6 +8712,18 @@ lookup_image (f, spec) | |||
| 8556 | img->vmargin += abs (img->relief); | 8712 | img->vmargin += abs (img->relief); |
| 8557 | } | 8713 | } |
| 8558 | 8714 | ||
| 8715 | if (! img->background_valid) | ||
| 8716 | { | ||
| 8717 | bg = image_spec_value (img->spec, QCbackground, NULL); | ||
| 8718 | if (!NILP (bg)) | ||
| 8719 | { | ||
| 8720 | img->background | ||
| 8721 | = x_alloc_image_color (f, img, bg, | ||
| 8722 | FRAME_BACKGROUND_PIXEL (f)); | ||
| 8723 | img->background_valid = 1; | ||
| 8724 | } | ||
| 8725 | } | ||
| 8726 | |||
| 8559 | /* Do image transformations and compute masks, unless we | 8727 | /* Do image transformations and compute masks, unless we |
| 8560 | don't have the image yet. */ | 8728 | don't have the image yet. */ |
| 8561 | if (!EQ (*img->type->type, Qpostscript)) | 8729 | if (!EQ (*img->type->type, Qpostscript)) |
| @@ -8672,7 +8840,7 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) | |||
| 8672 | xassert (interrupt_input_blocked); | 8840 | xassert (interrupt_input_blocked); |
| 8673 | 8841 | ||
| 8674 | if (depth <= 0) | 8842 | if (depth <= 0) |
| 8675 | depth = DefaultDepthOfScreen (screen); | 8843 | depth = one_w32_display_info.n_cbits; |
| 8676 | *ximg = XCreateImage (display, DefaultVisualOfScreen (screen), | 8844 | *ximg = XCreateImage (display, DefaultVisualOfScreen (screen), |
| 8677 | depth, ZPixmap, 0, NULL, width, height, | 8845 | depth, ZPixmap, 0, NULL, width, height, |
| 8678 | depth > 16 ? 32 : depth > 8 ? 16 : 8, 0); | 8846 | depth > 16 ? 32 : depth > 8 ? 16 : 8, 0); |
| @@ -8837,6 +9005,7 @@ enum xbm_keyword_index | |||
| 8837 | XBM_RELIEF, | 9005 | XBM_RELIEF, |
| 8838 | XBM_ALGORITHM, | 9006 | XBM_ALGORITHM, |
| 8839 | XBM_HEURISTIC_MASK, | 9007 | XBM_HEURISTIC_MASK, |
| 9008 | XBM_MASK, | ||
| 8840 | XBM_LAST | 9009 | XBM_LAST |
| 8841 | }; | 9010 | }; |
| 8842 | 9011 | ||
| @@ -9265,11 +9434,14 @@ xbm_load_image (f, img, contents, end) | |||
| 9265 | value = image_spec_value (img->spec, QCforeground, NULL); | 9434 | value = image_spec_value (img->spec, QCforeground, NULL); |
| 9266 | if (!NILP (value)) | 9435 | if (!NILP (value)) |
| 9267 | foreground = x_alloc_image_color (f, img, value, foreground); | 9436 | foreground = x_alloc_image_color (f, img, value, foreground); |
| 9268 | |||
| 9269 | value = image_spec_value (img->spec, QCbackground, NULL); | 9437 | value = image_spec_value (img->spec, QCbackground, NULL); |
| 9270 | if (!NILP (value)) | 9438 | if (!NILP (value)) |
| 9271 | background = x_alloc_image_color (f, img, value, background); | 9439 | { |
| 9272 | 9440 | background = x_alloc_image_color (f, img, value, background); | |
| 9441 | img->background = background; | ||
| 9442 | img->background_valid = 1; | ||
| 9443 | } | ||
| 9444 | |||
| 9273 | #if 0 /* TODO : Port image display to W32 */ | 9445 | #if 0 /* TODO : Port image display to W32 */ |
| 9274 | img->pixmap | 9446 | img->pixmap |
| 9275 | = XCreatePixmapFromBitmapData (FRAME_W32_DISPLAY (f), | 9447 | = XCreatePixmapFromBitmapData (FRAME_W32_DISPLAY (f), |
| @@ -9278,6 +9450,7 @@ xbm_load_image (f, img, contents, end) | |||
| 9278 | img->width, img->height, | 9450 | img->width, img->height, |
| 9279 | foreground, background, | 9451 | foreground, background, |
| 9280 | depth); | 9452 | depth); |
| 9453 | #endif | ||
| 9281 | xfree (data); | 9454 | xfree (data); |
| 9282 | 9455 | ||
| 9283 | if (img->pixmap == 0) | 9456 | if (img->pixmap == 0) |
| @@ -9287,7 +9460,6 @@ xbm_load_image (f, img, contents, end) | |||
| 9287 | } | 9460 | } |
| 9288 | else | 9461 | else |
| 9289 | success_p = 1; | 9462 | success_p = 1; |
| 9290 | #endif | ||
| 9291 | } | 9463 | } |
| 9292 | else | 9464 | else |
| 9293 | image_error ("Error loading XBM image `%s'", img->spec, Qnil); | 9465 | image_error ("Error loading XBM image `%s'", img->spec, Qnil); |
| @@ -9418,7 +9590,7 @@ xbm_load (f, img) | |||
| 9418 | bits = XBOOL_VECTOR (data)->data; | 9590 | bits = XBOOL_VECTOR (data)->data; |
| 9419 | #ifdef TODO /* image support. */ | 9591 | #ifdef TODO /* image support. */ |
| 9420 | /* Create the pixmap. */ | 9592 | /* Create the pixmap. */ |
| 9421 | depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f)); | 9593 | depth = one_w32_display_info.n_cbits; |
| 9422 | img->pixmap | 9594 | img->pixmap |
| 9423 | = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f), | 9595 | = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f), |
| 9424 | FRAME_X_WINDOW (f), | 9596 | FRAME_X_WINDOW (f), |
| @@ -9471,7 +9643,9 @@ enum xpm_keyword_index | |||
| 9471 | XPM_RELIEF, | 9643 | XPM_RELIEF, |
| 9472 | XPM_ALGORITHM, | 9644 | XPM_ALGORITHM, |
| 9473 | XPM_HEURISTIC_MASK, | 9645 | XPM_HEURISTIC_MASK, |
| 9646 | XPM_MASK, | ||
| 9474 | XPM_COLOR_SYMBOLS, | 9647 | XPM_COLOR_SYMBOLS, |
| 9648 | XPM_BACKGROUND, | ||
| 9475 | XPM_LAST | 9649 | XPM_LAST |
| 9476 | }; | 9650 | }; |
| 9477 | 9651 | ||
| @@ -9488,7 +9662,9 @@ static struct image_keyword xpm_format[XPM_LAST] = | |||
| 9488 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 9662 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 9489 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 9663 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 9490 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 9664 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 9491 | {":color-symbols", IMAGE_DONT_CHECK_VALUE_TYPE, 0} | 9665 | {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 9666 | {":color-symbols", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | ||
| 9667 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | ||
| 9492 | }; | 9668 | }; |
| 9493 | 9669 | ||
| 9494 | /* Structure describing the image type XBM. */ | 9670 | /* Structure describing the image type XBM. */ |
| @@ -10213,36 +10389,35 @@ x_build_heuristic_mask (f, img, how) | |||
| 10213 | { | 10389 | { |
| 10214 | Display *dpy = FRAME_W32_DISPLAY (f); | 10390 | Display *dpy = FRAME_W32_DISPLAY (f); |
| 10215 | XImage *ximg, *mask_img; | 10391 | XImage *ximg, *mask_img; |
| 10216 | int x, y, rc, look_at_corners_p; | 10392 | int x, y, rc, use_img_background; |
| 10217 | unsigned long bg; | 10393 | unsigned long bg = 0; |
| 10394 | |||
| 10395 | if (img->mask) | ||
| 10396 | { | ||
| 10397 | XFreePixmap (FRAME_X_DISPLAY (f), img->mask); | ||
| 10398 | img->mask = None; | ||
| 10399 | img->background_transparent_valid = 0; | ||
| 10400 | } | ||
| 10218 | 10401 | ||
| 10219 | BLOCK_INPUT; | ||
| 10220 | |||
| 10221 | /* Create an image and pixmap serving as mask. */ | 10402 | /* Create an image and pixmap serving as mask. */ |
| 10222 | rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1, | 10403 | rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1, |
| 10223 | &mask_img, &img->mask); | 10404 | &mask_img, &img->mask); |
| 10224 | if (!rc) | 10405 | if (!rc) |
| 10225 | { | 10406 | return 0; |
| 10226 | UNBLOCK_INPUT; | ||
| 10227 | return 0; | ||
| 10228 | } | ||
| 10229 | 10407 | ||
| 10230 | /* Get the X image of IMG->pixmap. */ | 10408 | /* Get the X image of IMG->pixmap. */ |
| 10231 | ximg = XGetImage (dpy, img->pixmap, 0, 0, img->width, img->height, | 10409 | ximg = XGetImage (dpy, img->pixmap, 0, 0, img->width, img->height, |
| 10232 | ~0, ZPixmap); | 10410 | ~0, ZPixmap); |
| 10233 | 10411 | ||
| 10234 | /* Determine the background color of ximg. If HOW is `(R G B)' | 10412 | /* Determine the background color of ximg. If HOW is `(R G B)' |
| 10235 | take that as color. Otherwise, try to determine the color | 10413 | take that as color. Otherwise, use the image's background color. */ |
| 10236 | heuristically. */ | 10414 | use_img_background = 1; |
| 10237 | look_at_corners_p = 1; | ||
| 10238 | 10415 | ||
| 10239 | if (CONSP (how)) | 10416 | if (CONSP (how)) |
| 10240 | { | 10417 | { |
| 10241 | int rgb[3], i = 0; | 10418 | int rgb[3], i; |
| 10242 | 10419 | ||
| 10243 | while (i < 3 | 10420 | for (i = 0; i < 3 && CONSP (how) && NATNUMP (XCAR (how)); ++i) |
| 10244 | && CONSP (how) | ||
| 10245 | && NATNUMP (XCAR (how))) | ||
| 10246 | { | 10421 | { |
| 10247 | rgb[i] = XFASTINT (XCAR (how)) & 0xffff; | 10422 | rgb[i] = XFASTINT (XCAR (how)) & 0xffff; |
| 10248 | how = XCDR (how); | 10423 | how = XCDR (how); |
| @@ -10251,44 +10426,14 @@ x_build_heuristic_mask (f, img, how) | |||
| 10251 | if (i == 3 && NILP (how)) | 10426 | if (i == 3 && NILP (how)) |
| 10252 | { | 10427 | { |
| 10253 | char color_name[30]; | 10428 | char color_name[30]; |
| 10254 | XColor exact, color; | ||
| 10255 | Colormap cmap; | ||
| 10256 | |||
| 10257 | sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]); | 10429 | sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]); |
| 10258 | 10430 | bg = x_alloc_image_color (f, img, build_string (color_name), 0); | |
| 10259 | cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); | 10431 | use_img_background = 0; |
| 10260 | if (XLookupColor (dpy, cmap, color_name, &exact, &color)) | ||
| 10261 | { | ||
| 10262 | bg = color.pixel; | ||
| 10263 | look_at_corners_p = 0; | ||
| 10264 | } | ||
| 10265 | } | 10432 | } |
| 10266 | } | 10433 | } |
| 10267 | 10434 | ||
| 10268 | if (look_at_corners_p) | 10435 | if (use_img_background) |
| 10269 | { | 10436 | bg = four_corners_best (ximg, img->width, img->height); |
| 10270 | unsigned long corners[4]; | ||
| 10271 | int i, best_count; | ||
| 10272 | |||
| 10273 | /* Get the colors at the corners of ximg. */ | ||
| 10274 | corners[0] = XGetPixel (ximg, 0, 0); | ||
| 10275 | corners[1] = XGetPixel (ximg, img->width - 1, 0); | ||
| 10276 | corners[2] = XGetPixel (ximg, img->width - 1, img->height - 1); | ||
| 10277 | corners[3] = XGetPixel (ximg, 0, img->height - 1); | ||
| 10278 | |||
| 10279 | /* Choose the most frequently found color as background. */ | ||
| 10280 | for (i = best_count = 0; i < 4; ++i) | ||
| 10281 | { | ||
| 10282 | int j, n; | ||
| 10283 | |||
| 10284 | for (j = n = 0; j < 4; ++j) | ||
| 10285 | if (corners[i] == corners[j]) | ||
| 10286 | ++n; | ||
| 10287 | |||
| 10288 | if (n > best_count) | ||
| 10289 | bg = corners[i], best_count = n; | ||
| 10290 | } | ||
| 10291 | } | ||
| 10292 | 10437 | ||
| 10293 | /* Set all bits in mask_img to 1 whose color in ximg is different | 10438 | /* Set all bits in mask_img to 1 whose color in ximg is different |
| 10294 | from the background color bg. */ | 10439 | from the background color bg. */ |
| @@ -10296,12 +10441,13 @@ x_build_heuristic_mask (f, img, how) | |||
| 10296 | for (x = 0; x < img->width; ++x) | 10441 | for (x = 0; x < img->width; ++x) |
| 10297 | XPutPixel (mask_img, x, y, XGetPixel (ximg, x, y) != bg); | 10442 | XPutPixel (mask_img, x, y, XGetPixel (ximg, x, y) != bg); |
| 10298 | 10443 | ||
| 10444 | /* Fill in the background_transparent field while we have the mask handy. */ | ||
| 10445 | image_background_transparent (img, f, mask_img); | ||
| 10446 | |||
| 10299 | /* Put mask_img into img->mask. */ | 10447 | /* Put mask_img into img->mask. */ |
| 10300 | x_put_x_image (f, mask_img, img->mask, img->width, img->height); | 10448 | x_put_x_image (f, mask_img, img->mask, img->width, img->height); |
| 10301 | x_destroy_x_image (mask_img); | 10449 | x_destroy_x_image (mask_img); |
| 10302 | XDestroyImage (ximg); | 10450 | XDestroyImage (ximg); |
| 10303 | |||
| 10304 | UNBLOCK_INPUT; | ||
| 10305 | 10451 | ||
| 10306 | return 1; | 10452 | return 1; |
| 10307 | } | 10453 | } |
| @@ -10333,6 +10479,9 @@ enum pbm_keyword_index | |||
| 10333 | PBM_RELIEF, | 10479 | PBM_RELIEF, |
| 10334 | PBM_ALGORITHM, | 10480 | PBM_ALGORITHM, |
| 10335 | PBM_HEURISTIC_MASK, | 10481 | PBM_HEURISTIC_MASK, |
| 10482 | PBM_MASK, | ||
| 10483 | PBM_FOREGROUND, | ||
| 10484 | PBM_BACKGROUND, | ||
| 10336 | PBM_LAST | 10485 | PBM_LAST |
| 10337 | }; | 10486 | }; |
| 10338 | 10487 | ||
| @@ -10592,8 +10741,12 @@ pbm_load (f, img) | |||
| 10592 | fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg); | 10741 | fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg); |
| 10593 | if (fmt[PBM_BACKGROUND].count | 10742 | if (fmt[PBM_BACKGROUND].count |
| 10594 | && STRINGP (fmt[PBM_BACKGROUND].value)) | 10743 | && STRINGP (fmt[PBM_BACKGROUND].value)) |
| 10595 | bg = x_alloc_image_color (f, img, fmt[PBM_BACKGROUND].value, bg); | 10744 | { |
| 10596 | 10745 | bg = x_alloc_image_color (f, img, fmt[PBM_BACKGROUND].value, bg); | |
| 10746 | img->background = bg; | ||
| 10747 | img->background_valid = 1; | ||
| 10748 | } | ||
| 10749 | |||
| 10597 | for (y = 0; y < height; ++y) | 10750 | for (y = 0; y < height; ++y) |
| 10598 | for (x = 0; x < width; ++x) | 10751 | for (x = 0; x < width; ++x) |
| 10599 | { | 10752 | { |
| @@ -10656,6 +10809,10 @@ pbm_load (f, img) | |||
| 10656 | img->colors = colors_in_color_table (&img->ncolors); | 10809 | img->colors = colors_in_color_table (&img->ncolors); |
| 10657 | free_color_table (); | 10810 | free_color_table (); |
| 10658 | 10811 | ||
| 10812 | /* Maybe fill in the background field while we have ximg handy. */ | ||
| 10813 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | ||
| 10814 | IMAGE_BACKGROUND (img, f, ximg); | ||
| 10815 | |||
| 10659 | /* Put the image into a pixmap. */ | 10816 | /* Put the image into a pixmap. */ |
| 10660 | x_put_x_image (f, ximg, img->pixmap, width, height); | 10817 | x_put_x_image (f, ximg, img->pixmap, width, height); |
| 10661 | x_destroy_x_image (ximg); | 10818 | x_destroy_x_image (ximg); |
| @@ -10699,6 +10856,8 @@ enum png_keyword_index | |||
| 10699 | PNG_RELIEF, | 10856 | PNG_RELIEF, |
| 10700 | PNG_ALGORITHM, | 10857 | PNG_ALGORITHM, |
| 10701 | PNG_HEURISTIC_MASK, | 10858 | PNG_HEURISTIC_MASK, |
| 10859 | PNG_MASK, | ||
| 10860 | PNG_BACKGROUND, | ||
| 10702 | PNG_LAST | 10861 | PNG_LAST |
| 10703 | }; | 10862 | }; |
| 10704 | 10863 | ||
| @@ -10714,7 +10873,9 @@ static struct image_keyword png_format[PNG_LAST] = | |||
| 10714 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 10873 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 10715 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 10874 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 10716 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 10875 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 10717 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} | 10876 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 10877 | {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | ||
| 10878 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | ||
| 10718 | }; | 10879 | }; |
| 10719 | 10880 | ||
| 10720 | /* Structure describing the image type `png'. */ | 10881 | /* Structure describing the image type `png'. */ |
| @@ -10816,10 +10977,10 @@ png_load (f, img) | |||
| 10816 | struct gcpro gcpro1; | 10977 | struct gcpro gcpro1; |
| 10817 | png_struct *png_ptr = NULL; | 10978 | png_struct *png_ptr = NULL; |
| 10818 | png_info *info_ptr = NULL, *end_info = NULL; | 10979 | png_info *info_ptr = NULL, *end_info = NULL; |
| 10819 | FILE *fp = NULL; | 10980 | FILE *volatile fp = NULL; |
| 10820 | png_byte sig[8]; | 10981 | png_byte sig[8]; |
| 10821 | png_byte *pixels = NULL; | 10982 | png_byte *volatile pixels = NULL; |
| 10822 | png_byte **rows = NULL; | 10983 | png_byte **volatile rows = NULL; |
| 10823 | png_uint_32 width, height; | 10984 | png_uint_32 width, height; |
| 10824 | int bit_depth, color_type, interlace_type; | 10985 | int bit_depth, color_type, interlace_type; |
| 10825 | png_byte channels; | 10986 | png_byte channels; |
| @@ -10988,8 +11149,28 @@ png_load (f, img) | |||
| 10988 | if (!transparent_p) | 11149 | if (!transparent_p) |
| 10989 | { | 11150 | { |
| 10990 | png_color_16 *image_background; | 11151 | png_color_16 *image_background; |
| 11152 | Lisp_Object specified_bg | ||
| 11153 | = image_spec_value (img->spec, QCbackground, NULL); | ||
| 11154 | |||
| 11155 | |||
| 11156 | if (STRINGP (specified_bg)) | ||
| 11157 | /* The user specified `:background', use that. */ | ||
| 11158 | { | ||
| 11159 | COLORREF color; | ||
| 11160 | if (w32_defined_color (f, XSTRING (specified_bg)->data, &color, 0)) | ||
| 11161 | { | ||
| 11162 | png_color_16 user_bg; | ||
| 11163 | |||
| 11164 | bzero (&user_bg, sizeof user_bg); | ||
| 11165 | user_bg.red = color.red; | ||
| 11166 | user_bg.green = color.green; | ||
| 11167 | user_bg.blue = color.blue; | ||
| 10991 | 11168 | ||
| 10992 | if (png_get_bKGD (png_ptr, info_ptr, &image_background)) | 11169 | png_set_background (png_ptr, &user_bg, |
| 11170 | PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); | ||
| 11171 | } | ||
| 11172 | } | ||
| 11173 | else if (png_get_bKGD (png_ptr, info_ptr, &image_background)) | ||
| 10993 | /* Image contains a background color with which to | 11174 | /* Image contains a background color with which to |
| 10994 | combine the image. */ | 11175 | combine the image. */ |
| 10995 | png_set_background (png_ptr, image_background, | 11176 | png_set_background (png_ptr, image_background, |
| @@ -11003,11 +11184,9 @@ png_load (f, img) | |||
| 11003 | Colormap cmap; | 11184 | Colormap cmap; |
| 11004 | png_color_16 frame_background; | 11185 | png_color_16 frame_background; |
| 11005 | 11186 | ||
| 11006 | BLOCK_INPUT; | 11187 | cmap = FRAME_X_COLORMAP (f); |
| 11007 | cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); | ||
| 11008 | color.pixel = FRAME_BACKGROUND_PIXEL (f); | 11188 | color.pixel = FRAME_BACKGROUND_PIXEL (f); |
| 11009 | XQueryColor (FRAME_W32_DISPLAY (f), cmap, &color); | 11189 | x_query_color (f, &color); |
| 11010 | UNBLOCK_INPUT; | ||
| 11011 | 11190 | ||
| 11012 | bzero (&frame_background, sizeof frame_background); | 11191 | bzero (&frame_background, sizeof frame_background); |
| 11013 | frame_background.red = color.red; | 11192 | frame_background.red = color.red; |
| @@ -11048,15 +11227,10 @@ png_load (f, img) | |||
| 11048 | fp = NULL; | 11227 | fp = NULL; |
| 11049 | } | 11228 | } |
| 11050 | 11229 | ||
| 11051 | BLOCK_INPUT; | ||
| 11052 | |||
| 11053 | /* Create the X image and pixmap. */ | 11230 | /* Create the X image and pixmap. */ |
| 11054 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, | 11231 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, |
| 11055 | &img->pixmap)) | 11232 | &img->pixmap)) |
| 11056 | { | 11233 | goto error; |
| 11057 | UNBLOCK_INPUT; | ||
| 11058 | goto error; | ||
| 11059 | } | ||
| 11060 | 11234 | ||
| 11061 | /* Create an image and pixmap serving as mask if the PNG image | 11235 | /* Create an image and pixmap serving as mask if the PNG image |
| 11062 | contains an alpha channel. */ | 11236 | contains an alpha channel. */ |
| @@ -11068,7 +11242,6 @@ png_load (f, img) | |||
| 11068 | x_destroy_x_image (ximg); | 11242 | x_destroy_x_image (ximg); |
| 11069 | XFreePixmap (FRAME_W32_DISPLAY (f), img->pixmap); | 11243 | XFreePixmap (FRAME_W32_DISPLAY (f), img->pixmap); |
| 11070 | img->pixmap = 0; | 11244 | img->pixmap = 0; |
| 11071 | UNBLOCK_INPUT; | ||
| 11072 | goto error; | 11245 | goto error; |
| 11073 | } | 11246 | } |
| 11074 | 11247 | ||
| @@ -11113,6 +11286,18 @@ png_load (f, img) | |||
| 11113 | } | 11286 | } |
| 11114 | } | 11287 | } |
| 11115 | 11288 | ||
| 11289 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | ||
| 11290 | /* Set IMG's background color from the PNG image, unless the user | ||
| 11291 | overrode it. */ | ||
| 11292 | { | ||
| 11293 | png_color_16 *bg; | ||
| 11294 | if (png_get_bKGD (png_ptr, info_ptr, &bg)) | ||
| 11295 | { | ||
| 11296 | img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue); | ||
| 11297 | img->background_valid = 1; | ||
| 11298 | } | ||
| 11299 | } | ||
| 11300 | |||
| 11116 | /* Remember colors allocated for this image. */ | 11301 | /* Remember colors allocated for this image. */ |
| 11117 | img->colors = colors_in_color_table (&img->ncolors); | 11302 | img->colors = colors_in_color_table (&img->ncolors); |
| 11118 | free_color_table (); | 11303 | free_color_table (); |
| @@ -11125,6 +11310,9 @@ png_load (f, img) | |||
| 11125 | img->width = width; | 11310 | img->width = width; |
| 11126 | img->height = height; | 11311 | img->height = height; |
| 11127 | 11312 | ||
| 11313 | /* Maybe fill in the background field while we have ximg handy. */ | ||
| 11314 | IMAGE_BACKGROUND (img, f, ximg); | ||
| 11315 | |||
| 11128 | /* Put the image into the pixmap, then free the X image and its buffer. */ | 11316 | /* Put the image into the pixmap, then free the X image and its buffer. */ |
| 11129 | x_put_x_image (f, ximg, img->pixmap, width, height); | 11317 | x_put_x_image (f, ximg, img->pixmap, width, height); |
| 11130 | x_destroy_x_image (ximg); | 11318 | x_destroy_x_image (ximg); |
| @@ -11132,11 +11320,14 @@ png_load (f, img) | |||
| 11132 | /* Same for the mask. */ | 11320 | /* Same for the mask. */ |
| 11133 | if (mask_img) | 11321 | if (mask_img) |
| 11134 | { | 11322 | { |
| 11323 | /* Fill in the background_transparent field while we have the mask | ||
| 11324 | handy. */ | ||
| 11325 | image_background_transparent (img, f, mask_img); | ||
| 11326 | |||
| 11135 | x_put_x_image (f, mask_img, img->mask, img->width, img->height); | 11327 | x_put_x_image (f, mask_img, img->mask, img->width, img->height); |
| 11136 | x_destroy_x_image (mask_img); | 11328 | x_destroy_x_image (mask_img); |
| 11137 | } | 11329 | } |
| 11138 | 11330 | ||
| 11139 | UNBLOCK_INPUT; | ||
| 11140 | UNGCPRO; | 11331 | UNGCPRO; |
| 11141 | return 1; | 11332 | return 1; |
| 11142 | } | 11333 | } |
| @@ -11185,6 +11376,8 @@ enum jpeg_keyword_index | |||
| 11185 | JPEG_RELIEF, | 11376 | JPEG_RELIEF, |
| 11186 | JPEG_ALGORITHM, | 11377 | JPEG_ALGORITHM, |
| 11187 | JPEG_HEURISTIC_MASK, | 11378 | JPEG_HEURISTIC_MASK, |
| 11379 | JPEG_MASK, | ||
| 11380 | JPEG_BACKGROUND, | ||
| 11188 | JPEG_LAST | 11381 | JPEG_LAST |
| 11189 | }; | 11382 | }; |
| 11190 | 11383 | ||
| @@ -11199,8 +11392,10 @@ static struct image_keyword jpeg_format[JPEG_LAST] = | |||
| 11199 | {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, | 11392 | {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, |
| 11200 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 11393 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 11201 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 11394 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 11202 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 11395 | {":conversions", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 11203 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} | 11396 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 11397 | {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | ||
| 11398 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | ||
| 11204 | }; | 11399 | }; |
| 11205 | 11400 | ||
| 11206 | /* Structure describing the image type `jpeg'. */ | 11401 | /* Structure describing the image type `jpeg'. */ |
| @@ -11357,7 +11552,7 @@ jpeg_load (f, img) | |||
| 11357 | struct my_jpeg_error_mgr mgr; | 11552 | struct my_jpeg_error_mgr mgr; |
| 11358 | Lisp_Object file, specified_file; | 11553 | Lisp_Object file, specified_file; |
| 11359 | Lisp_Object specified_data; | 11554 | Lisp_Object specified_data; |
| 11360 | FILE *fp = NULL; | 11555 | FILE * volatile fp = NULL; |
| 11361 | JSAMPARRAY buffer; | 11556 | JSAMPARRAY buffer; |
| 11362 | int row_stride, x, y; | 11557 | int row_stride, x, y; |
| 11363 | XImage *ximg = NULL; | 11558 | XImage *ximg = NULL; |
| @@ -11393,8 +11588,8 @@ jpeg_load (f, img) | |||
| 11393 | 11588 | ||
| 11394 | /* Customize libjpeg's error handling to call my_error_exit when an | 11589 | /* Customize libjpeg's error handling to call my_error_exit when an |
| 11395 | error is detected. This function will perform a longjmp. */ | 11590 | error is detected. This function will perform a longjmp. */ |
| 11396 | mgr.pub.error_exit = my_error_exit; | ||
| 11397 | cinfo.err = jpeg_std_error (&mgr.pub); | 11591 | cinfo.err = jpeg_std_error (&mgr.pub); |
| 11592 | mgr.pub.error_exit = my_error_exit; | ||
| 11398 | 11593 | ||
| 11399 | if ((rc = setjmp (mgr.setjmp_buffer)) != 0) | 11594 | if ((rc = setjmp (mgr.setjmp_buffer)) != 0) |
| 11400 | { | 11595 | { |
| @@ -11411,8 +11606,6 @@ jpeg_load (f, img) | |||
| 11411 | if (fp) | 11606 | if (fp) |
| 11412 | fclose (fp); | 11607 | fclose (fp); |
| 11413 | jpeg_destroy_decompress (&cinfo); | 11608 | jpeg_destroy_decompress (&cinfo); |
| 11414 | |||
| 11415 | BLOCK_INPUT; | ||
| 11416 | 11609 | ||
| 11417 | /* If we already have an XImage, free that. */ | 11610 | /* If we already have an XImage, free that. */ |
| 11418 | x_destroy_x_image (ximg); | 11611 | x_destroy_x_image (ximg); |
| @@ -11420,7 +11613,6 @@ jpeg_load (f, img) | |||
| 11420 | /* Free pixmap and colors. */ | 11613 | /* Free pixmap and colors. */ |
| 11421 | x_clear_image (f, img); | 11614 | x_clear_image (f, img); |
| 11422 | 11615 | ||
| 11423 | UNBLOCK_INPUT; | ||
| 11424 | UNGCPRO; | 11616 | UNGCPRO; |
| 11425 | return 0; | 11617 | return 0; |
| 11426 | } | 11618 | } |
| @@ -11444,15 +11636,10 @@ jpeg_load (f, img) | |||
| 11444 | width = img->width = cinfo.output_width; | 11636 | width = img->width = cinfo.output_width; |
| 11445 | height = img->height = cinfo.output_height; | 11637 | height = img->height = cinfo.output_height; |
| 11446 | 11638 | ||
| 11447 | BLOCK_INPUT; | ||
| 11448 | |||
| 11449 | /* Create X image and pixmap. */ | 11639 | /* Create X image and pixmap. */ |
| 11450 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, | 11640 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, |
| 11451 | &img->pixmap)) | 11641 | &img->pixmap)) |
| 11452 | { | 11642 | longjmp (mgr.setjmp_buffer, 2); |
| 11453 | UNBLOCK_INPUT; | ||
| 11454 | longjmp (mgr.setjmp_buffer, 2); | ||
| 11455 | } | ||
| 11456 | 11643 | ||
| 11457 | /* Allocate colors. When color quantization is used, | 11644 | /* Allocate colors. When color quantization is used, |
| 11458 | cinfo.actual_number_of_colors has been set with the number of | 11645 | cinfo.actual_number_of_colors has been set with the number of |
| @@ -11509,6 +11696,10 @@ jpeg_load (f, img) | |||
| 11509 | if (fp) | 11696 | if (fp) |
| 11510 | fclose (fp); | 11697 | fclose (fp); |
| 11511 | 11698 | ||
| 11699 | /* Maybe fill in the background field while we have ximg handy. */ | ||
| 11700 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | ||
| 11701 | IMAGE_BACKGROUND (img, f, ximg); | ||
| 11702 | |||
| 11512 | /* Put the image into the pixmap. */ | 11703 | /* Put the image into the pixmap. */ |
| 11513 | x_put_x_image (f, ximg, img->pixmap, width, height); | 11704 | x_put_x_image (f, ximg, img->pixmap, width, height); |
| 11514 | x_destroy_x_image (ximg); | 11705 | x_destroy_x_image (ximg); |
| @@ -11548,6 +11739,8 @@ enum tiff_keyword_index | |||
| 11548 | TIFF_RELIEF, | 11739 | TIFF_RELIEF, |
| 11549 | TIFF_ALGORITHM, | 11740 | TIFF_ALGORITHM, |
| 11550 | TIFF_HEURISTIC_MASK, | 11741 | TIFF_HEURISTIC_MASK, |
| 11742 | TIFF_MASK, | ||
| 11743 | TIFF_BACKGROUND, | ||
| 11551 | TIFF_LAST | 11744 | TIFF_LAST |
| 11552 | }; | 11745 | }; |
| 11553 | 11746 | ||
| @@ -11562,8 +11755,10 @@ static struct image_keyword tiff_format[TIFF_LAST] = | |||
| 11562 | {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, | 11755 | {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, |
| 11563 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 11756 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 11564 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 11757 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 11565 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 11758 | {":conversions", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 11566 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} | 11759 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 11760 | {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | ||
| 11761 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | ||
| 11567 | }; | 11762 | }; |
| 11568 | 11763 | ||
| 11569 | /* Structure describing the image type `tiff'. */ | 11764 | /* Structure describing the image type `tiff'. */ |
| @@ -11851,13 +12046,17 @@ tiff_load (f, img) | |||
| 11851 | img->colors = colors_in_color_table (&img->ncolors); | 12046 | img->colors = colors_in_color_table (&img->ncolors); |
| 11852 | free_color_table (); | 12047 | free_color_table (); |
| 11853 | 12048 | ||
| 12049 | img->width = width; | ||
| 12050 | img->height = height; | ||
| 12051 | |||
| 12052 | /* Maybe fill in the background field while we have ximg handy. */ | ||
| 12053 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | ||
| 12054 | IMAGE_BACKGROUND (img, f, ximg); | ||
| 12055 | |||
| 11854 | /* Put the image into the pixmap, then free the X image and its buffer. */ | 12056 | /* Put the image into the pixmap, then free the X image and its buffer. */ |
| 11855 | x_put_x_image (f, ximg, img->pixmap, width, height); | 12057 | x_put_x_image (f, ximg, img->pixmap, width, height); |
| 11856 | x_destroy_x_image (ximg); | 12058 | x_destroy_x_image (ximg); |
| 11857 | xfree (buf); | 12059 | xfree (buf); |
| 11858 | |||
| 11859 | img->width = width; | ||
| 11860 | img->height = height; | ||
| 11861 | 12060 | ||
| 11862 | UNGCPRO; | 12061 | UNGCPRO; |
| 11863 | return 1; | 12062 | return 1; |
| @@ -11894,7 +12093,9 @@ enum gif_keyword_index | |||
| 11894 | GIF_RELIEF, | 12093 | GIF_RELIEF, |
| 11895 | GIF_ALGORITHM, | 12094 | GIF_ALGORITHM, |
| 11896 | GIF_HEURISTIC_MASK, | 12095 | GIF_HEURISTIC_MASK, |
| 12096 | GIF_MASK, | ||
| 11897 | GIF_IMAGE, | 12097 | GIF_IMAGE, |
| 12098 | GIF_BACKGROUND, | ||
| 11898 | GIF_LAST | 12099 | GIF_LAST |
| 11899 | }; | 12100 | }; |
| 11900 | 12101 | ||
| @@ -11911,7 +12112,9 @@ static struct image_keyword gif_format[GIF_LAST] = | |||
| 11911 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 12112 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 11912 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 12113 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 11913 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 12114 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 11914 | {":image", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0} | 12115 | {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 12116 | {":image", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, | ||
| 12117 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | ||
| 11915 | }; | 12118 | }; |
| 11916 | 12119 | ||
| 11917 | /* Structure describing the image type `gif'. */ | 12120 | /* Structure describing the image type `gif'. */ |
| @@ -12062,12 +12265,9 @@ gif_load (f, img) | |||
| 12062 | width = img->width = gif->SWidth; | 12265 | width = img->width = gif->SWidth; |
| 12063 | height = img->height = gif->SHeight; | 12266 | height = img->height = gif->SHeight; |
| 12064 | 12267 | ||
| 12065 | BLOCK_INPUT; | ||
| 12066 | |||
| 12067 | /* Create the X image and pixmap. */ | 12268 | /* Create the X image and pixmap. */ |
| 12068 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) | 12269 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) |
| 12069 | { | 12270 | { |
| 12070 | UNBLOCK_INPUT; | ||
| 12071 | DGifCloseFile (gif); | 12271 | DGifCloseFile (gif); |
| 12072 | UNGCPRO; | 12272 | UNGCPRO; |
| 12073 | return 0; | 12273 | return 0; |
| @@ -12126,7 +12326,7 @@ gif_load (f, img) | |||
| 12126 | { | 12326 | { |
| 12127 | static int interlace_start[] = {0, 4, 2, 1}; | 12327 | static int interlace_start[] = {0, 4, 2, 1}; |
| 12128 | static int interlace_increment[] = {8, 8, 4, 2}; | 12328 | static int interlace_increment[] = {8, 8, 4, 2}; |
| 12129 | int pass, inc; | 12329 | int pass; |
| 12130 | int row = interlace_start[0]; | 12330 | int row = interlace_start[0]; |
| 12131 | 12331 | ||
| 12132 | pass = 0; | 12332 | pass = 0; |
| @@ -12161,11 +12361,14 @@ gif_load (f, img) | |||
| 12161 | } | 12361 | } |
| 12162 | 12362 | ||
| 12163 | DGifCloseFile (gif); | 12363 | DGifCloseFile (gif); |
| 12164 | 12364 | ||
| 12365 | /* Maybe fill in the background field while we have ximg handy. */ | ||
| 12366 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | ||
| 12367 | IMAGE_BACKGROUND (img, f, ximg); | ||
| 12368 | |||
| 12165 | /* Put the image into the pixmap, then free the X image and its buffer. */ | 12369 | /* Put the image into the pixmap, then free the X image and its buffer. */ |
| 12166 | x_put_x_image (f, ximg, img->pixmap, width, height); | 12370 | x_put_x_image (f, ximg, img->pixmap, width, height); |
| 12167 | x_destroy_x_image (ximg); | 12371 | x_destroy_x_image (ximg); |
| 12168 | UNBLOCK_INPUT; | ||
| 12169 | 12372 | ||
| 12170 | UNGCPRO; | 12373 | UNGCPRO; |
| 12171 | return 1; | 12374 | return 1; |
| @@ -12207,6 +12410,8 @@ enum gs_keyword_index | |||
| 12207 | GS_RELIEF, | 12410 | GS_RELIEF, |
| 12208 | GS_ALGORITHM, | 12411 | GS_ALGORITHM, |
| 12209 | GS_HEURISTIC_MASK, | 12412 | GS_HEURISTIC_MASK, |
| 12413 | GS_MASK, | ||
| 12414 | GS_BACKGROUND, | ||
| 12210 | GS_LAST | 12415 | GS_LAST |
| 12211 | }; | 12416 | }; |
| 12212 | 12417 | ||
| @@ -12225,7 +12430,9 @@ static struct image_keyword gs_format[GS_LAST] = | |||
| 12225 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 12430 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 12226 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 12431 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 12227 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 12432 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 12228 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} | 12433 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 12434 | {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | ||
| 12435 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | ||
| 12229 | }; | 12436 | }; |
| 12230 | 12437 | ||
| 12231 | /* Structure describing the image type `ghostscript'. */ | 12438 | /* Structure describing the image type `ghostscript'. */ |
| @@ -12327,7 +12534,7 @@ gs_load (f, img) | |||
| 12327 | xassert (img->pixmap == 0); | 12534 | xassert (img->pixmap == 0); |
| 12328 | img->pixmap = XCreatePixmap (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), | 12535 | img->pixmap = XCreatePixmap (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), |
| 12329 | img->width, img->height, | 12536 | img->width, img->height, |
| 12330 | DefaultDepthOfScreen (FRAME_X_SCREEN (f))); | 12537 | one_w32_display_info.n_cbits); |
| 12331 | UNBLOCK_INPUT; | 12538 | UNBLOCK_INPUT; |
| 12332 | 12539 | ||
| 12333 | if (!img->pixmap) | 12540 | if (!img->pixmap) |
| @@ -13175,7 +13382,6 @@ Text larger than the specified size is clipped. */) | |||
| 13175 | { | 13382 | { |
| 13176 | struct frame *f; | 13383 | struct frame *f; |
| 13177 | struct window *w; | 13384 | struct window *w; |
| 13178 | Lisp_Object buffer, top, left, max_width, max_height; | ||
| 13179 | int root_x, root_y; | 13385 | int root_x, root_y; |
| 13180 | struct buffer *old_buffer; | 13386 | struct buffer *old_buffer; |
| 13181 | struct text_pos pos; | 13387 | struct text_pos pos; |