diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32fns.c | 327 |
1 files changed, 232 insertions, 95 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 2fbf0bd0880..82767a029c1 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -2287,7 +2287,7 @@ x_set_cursor_color (f, arg, oldval) | |||
| 2287 | fore_pixel = FRAME_BACKGROUND_PIXEL (f); | 2287 | fore_pixel = FRAME_BACKGROUND_PIXEL (f); |
| 2288 | } | 2288 | } |
| 2289 | 2289 | ||
| 2290 | FRAME_FOREGROUND_PIXEL (f) = fore_pixel; | 2290 | f->output_data.w32->cursor_foreground_pixel = fore_pixel; |
| 2291 | f->output_data.w32->cursor_pixel = pixel; | 2291 | f->output_data.w32->cursor_pixel = pixel; |
| 2292 | 2292 | ||
| 2293 | if (FRAME_W32_WINDOW (f) != 0) | 2293 | if (FRAME_W32_WINDOW (f) != 0) |
| @@ -6640,8 +6640,8 @@ w32_to_x_font (lplogfont, lpxstr, len, specific_charset) | |||
| 6640 | char height_dpi[8]; | 6640 | char height_dpi[8]; |
| 6641 | char width_pixels[8]; | 6641 | char width_pixels[8]; |
| 6642 | char *fontname_dash; | 6642 | char *fontname_dash; |
| 6643 | int display_resy = one_w32_display_info.resy; | 6643 | int display_resy = (int) one_w32_display_info.resy; |
| 6644 | int display_resx = one_w32_display_info.resx; | 6644 | int display_resx = (int) one_w32_display_info.resx; |
| 6645 | int bufsz; | 6645 | int bufsz; |
| 6646 | struct coding_system coding; | 6646 | struct coding_system coding; |
| 6647 | 6647 | ||
| @@ -6757,7 +6757,7 @@ x_to_w32_font (lpxstr, lplogfont) | |||
| 6757 | char name[50], weight[20], slant, pitch, pixels[10], height[10], | 6757 | char name[50], weight[20], slant, pitch, pixels[10], height[10], |
| 6758 | width[10], resy[10], remainder[50]; | 6758 | width[10], resy[10], remainder[50]; |
| 6759 | char * encoding; | 6759 | char * encoding; |
| 6760 | int dpi = one_w32_display_info.resy; | 6760 | int dpi = (int) one_w32_display_info.resy; |
| 6761 | 6761 | ||
| 6762 | fields = sscanf (lpxstr, | 6762 | fields = sscanf (lpxstr, |
| 6763 | "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%9[^-]-%c-%9[^-]-%49s", | 6763 | "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%9[^-]-%c-%9[^-]-%49s", |
| @@ -8499,6 +8499,64 @@ image_spec_value (spec, key, found) | |||
| 8499 | } | 8499 | } |
| 8500 | 8500 | ||
| 8501 | 8501 | ||
| 8502 | #ifdef HAVE_IMAGES | ||
| 8503 | DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0, | ||
| 8504 | doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT). | ||
| 8505 | PIXELS non-nil means return the size in pixels, otherwise return the | ||
| 8506 | size in canonical character units. | ||
| 8507 | FRAME is the frame on which the image will be displayed. FRAME nil | ||
| 8508 | or omitted means use the selected frame. */) | ||
| 8509 | (spec, pixels, frame) | ||
| 8510 | Lisp_Object spec, pixels, frame; | ||
| 8511 | { | ||
| 8512 | Lisp_Object size; | ||
| 8513 | |||
| 8514 | size = Qnil; | ||
| 8515 | if (valid_image_p (spec)) | ||
| 8516 | { | ||
| 8517 | struct frame *f = check_x_frame (frame); | ||
| 8518 | int id = lookup_image (f, spec); | ||
| 8519 | struct image *img = IMAGE_FROM_ID (f, id); | ||
| 8520 | int width = img->width + 2 * img->hmargin; | ||
| 8521 | int height = img->height + 2 * img->vmargin; | ||
| 8522 | |||
| 8523 | if (NILP (pixels)) | ||
| 8524 | size = Fcons (make_float ((double) width / CANON_X_UNIT (f)), | ||
| 8525 | make_float ((double) height / CANON_Y_UNIT (f))); | ||
| 8526 | else | ||
| 8527 | size = Fcons (make_number (width), make_number (height)); | ||
| 8528 | } | ||
| 8529 | else | ||
| 8530 | error ("Invalid image specification"); | ||
| 8531 | |||
| 8532 | return size; | ||
| 8533 | } | ||
| 8534 | |||
| 8535 | |||
| 8536 | DEFUN ("image-mask-p", Fimage_mask_p, Simage_mask_p, 1, 2, 0, | ||
| 8537 | doc: /* Return t if image SPEC has a mask bitmap. | ||
| 8538 | FRAME is the frame on which the image will be displayed. FRAME nil | ||
| 8539 | or omitted means use the selected frame. */) | ||
| 8540 | (spec, frame) | ||
| 8541 | Lisp_Object spec, frame; | ||
| 8542 | { | ||
| 8543 | Lisp_Object mask; | ||
| 8544 | |||
| 8545 | mask = Qnil; | ||
| 8546 | if (valid_image_p (spec)) | ||
| 8547 | { | ||
| 8548 | struct frame *f = check_x_frame (frame); | ||
| 8549 | int id = lookup_image (f, spec); | ||
| 8550 | struct image *img = IMAGE_FROM_ID (f, id); | ||
| 8551 | if (img->mask) | ||
| 8552 | mask = Qt; | ||
| 8553 | } | ||
| 8554 | else | ||
| 8555 | error ("Invalid image specification"); | ||
| 8556 | |||
| 8557 | return mask; | ||
| 8558 | } | ||
| 8559 | #endif | ||
| 8502 | 8560 | ||
| 8503 | 8561 | ||
| 8504 | /*********************************************************************** | 8562 | /*********************************************************************** |
| @@ -8601,7 +8659,7 @@ image_ascent (img, face) | |||
| 8601 | ascent = height / 2; | 8659 | ascent = height / 2; |
| 8602 | } | 8660 | } |
| 8603 | else | 8661 | else |
| 8604 | ascent = height * img->ascent / 100.0; | 8662 | ascent = (int) (height * img->ascent / 100.0); |
| 8605 | 8663 | ||
| 8606 | return ascent; | 8664 | return ascent; |
| 8607 | } | 8665 | } |
| @@ -8610,20 +8668,21 @@ image_ascent (img, face) | |||
| 8610 | 8668 | ||
| 8611 | /* Image background colors. */ | 8669 | /* Image background colors. */ |
| 8612 | 8670 | ||
| 8613 | static unsigned long | 8671 | /* Find the "best" corner color of a bitmap. XIMG is assumed to a device |
| 8672 | context with the bitmap selected. */ | ||
| 8673 | static COLORREF | ||
| 8614 | four_corners_best (ximg, width, height) | 8674 | four_corners_best (ximg, width, height) |
| 8615 | XImage *ximg; | 8675 | HDC ximg; |
| 8616 | unsigned long width, height; | 8676 | unsigned long width, height; |
| 8617 | { | 8677 | { |
| 8618 | #if 0 /* TODO: Image support. */ | 8678 | COLORREF corners[4], best; |
| 8619 | unsigned long corners[4], best; | ||
| 8620 | int i, best_count; | 8679 | int i, best_count; |
| 8621 | 8680 | ||
| 8622 | /* Get the colors at the corners of ximg. */ | 8681 | /* Get the colors at the corners of ximg. */ |
| 8623 | corners[0] = XGetPixel (ximg, 0, 0); | 8682 | corners[0] = GetPixel (ximg, 0, 0); |
| 8624 | corners[1] = XGetPixel (ximg, width - 1, 0); | 8683 | corners[1] = GetPixel (ximg, width - 1, 0); |
| 8625 | corners[2] = XGetPixel (ximg, width - 1, height - 1); | 8684 | corners[2] = GetPixel (ximg, width - 1, height - 1); |
| 8626 | corners[3] = XGetPixel (ximg, 0, height - 1); | 8685 | corners[3] = GetPixel (ximg, 0, height - 1); |
| 8627 | 8686 | ||
| 8628 | /* Choose the most frequently found color as background. */ | 8687 | /* Choose the most frequently found color as background. */ |
| 8629 | for (i = best_count = 0; i < 4; ++i) | 8688 | for (i = best_count = 0; i < 4; ++i) |
| @@ -8639,9 +8698,6 @@ four_corners_best (ximg, width, height) | |||
| 8639 | } | 8698 | } |
| 8640 | 8699 | ||
| 8641 | return best; | 8700 | return best; |
| 8642 | #else | ||
| 8643 | return 0; | ||
| 8644 | #endif | ||
| 8645 | } | 8701 | } |
| 8646 | 8702 | ||
| 8647 | /* Return the `background' field of IMG. If IMG doesn't have one yet, | 8703 | /* Return the `background' field of IMG. If IMG doesn't have one yet, |
| @@ -8739,18 +8795,17 @@ x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p) | |||
| 8739 | struct image *img; | 8795 | struct image *img; |
| 8740 | int pixmap_p, mask_p, colors_p; | 8796 | int pixmap_p, mask_p, colors_p; |
| 8741 | { | 8797 | { |
| 8742 | #if 0 /* TODO: W32 image support */ | ||
| 8743 | if (pixmap_p && img->pixmap) | 8798 | if (pixmap_p && img->pixmap) |
| 8744 | { | 8799 | { |
| 8745 | XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap); | 8800 | DeleteObject (img->pixmap); |
| 8746 | img->pixmap = None; | 8801 | img->pixmap = NULL; |
| 8747 | img->background_valid = 0; | 8802 | img->background_valid = 0; |
| 8748 | } | 8803 | } |
| 8749 | 8804 | ||
| 8750 | if (mask_p && img->mask) | 8805 | if (mask_p && img->mask) |
| 8751 | { | 8806 | { |
| 8752 | XFreePixmap (FRAME_X_DISPLAY (f), img->mask); | 8807 | DeleteObject (img->mask); |
| 8753 | img->mask = None; | 8808 | img->mask = NULL; |
| 8754 | img->background_transparent_valid = 0; | 8809 | img->background_transparent_valid = 0; |
| 8755 | } | 8810 | } |
| 8756 | 8811 | ||
| @@ -8761,7 +8816,6 @@ x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p) | |||
| 8761 | img->colors = NULL; | 8816 | img->colors = NULL; |
| 8762 | img->ncolors = 0; | 8817 | img->ncolors = 0; |
| 8763 | } | 8818 | } |
| 8764 | #endif | ||
| 8765 | } | 8819 | } |
| 8766 | 8820 | ||
| 8767 | /* Free X resources of image IMG which is used on frame F. */ | 8821 | /* Free X resources of image IMG which is used on frame F. */ |
| @@ -8771,18 +8825,18 @@ x_clear_image (f, img) | |||
| 8771 | struct frame *f; | 8825 | struct frame *f; |
| 8772 | struct image *img; | 8826 | struct image *img; |
| 8773 | { | 8827 | { |
| 8774 | #if 0 /* TODO: W32 image support */ | ||
| 8775 | |||
| 8776 | if (img->pixmap) | 8828 | if (img->pixmap) |
| 8777 | { | 8829 | { |
| 8778 | BLOCK_INPUT; | 8830 | BLOCK_INPUT; |
| 8779 | XFreePixmap (NULL, img->pixmap); | 8831 | DeleteObject (img->pixmap); |
| 8780 | img->pixmap = 0; | 8832 | img->pixmap = 0; |
| 8781 | UNBLOCK_INPUT; | 8833 | UNBLOCK_INPUT; |
| 8782 | } | 8834 | } |
| 8783 | 8835 | ||
| 8784 | if (img->ncolors) | 8836 | if (img->ncolors) |
| 8785 | { | 8837 | { |
| 8838 | #if 0 /* TODO: color table support */ | ||
| 8839 | |||
| 8786 | int class = FRAME_W32_DISPLAY_INFO (f)->visual->class; | 8840 | int class = FRAME_W32_DISPLAY_INFO (f)->visual->class; |
| 8787 | 8841 | ||
| 8788 | /* If display has an immutable color map, freeing colors is not | 8842 | /* If display has an immutable color map, freeing colors is not |
| @@ -8798,12 +8852,12 @@ x_clear_image (f, img) | |||
| 8798 | img->ncolors, 0); | 8852 | img->ncolors, 0); |
| 8799 | UNBLOCK_INPUT; | 8853 | UNBLOCK_INPUT; |
| 8800 | } | 8854 | } |
| 8855 | #endif | ||
| 8801 | 8856 | ||
| 8802 | xfree (img->colors); | 8857 | xfree (img->colors); |
| 8803 | img->colors = NULL; | 8858 | img->colors = NULL; |
| 8804 | img->ncolors = 0; | 8859 | img->ncolors = 0; |
| 8805 | } | 8860 | } |
| 8806 | #endif | ||
| 8807 | } | 8861 | } |
| 8808 | 8862 | ||
| 8809 | 8863 | ||
| @@ -8819,7 +8873,6 @@ x_alloc_image_color (f, img, color_name, dflt) | |||
| 8819 | Lisp_Object color_name; | 8873 | Lisp_Object color_name; |
| 8820 | unsigned long dflt; | 8874 | unsigned long dflt; |
| 8821 | { | 8875 | { |
| 8822 | #if 0 /* TODO: allocing colors. */ | ||
| 8823 | XColor color; | 8876 | XColor color; |
| 8824 | unsigned long result; | 8877 | unsigned long result; |
| 8825 | 8878 | ||
| @@ -8839,8 +8892,6 @@ x_alloc_image_color (f, img, color_name, dflt) | |||
| 8839 | else | 8892 | else |
| 8840 | result = dflt; | 8893 | result = dflt; |
| 8841 | return result; | 8894 | return result; |
| 8842 | #endif | ||
| 8843 | return 0; | ||
| 8844 | } | 8895 | } |
| 8845 | 8896 | ||
| 8846 | 8897 | ||
| @@ -9016,7 +9067,7 @@ postprocess_image (f, img) | |||
| 9016 | } | 9067 | } |
| 9017 | else if (NILP (mask) && found_p && img->mask) | 9068 | else if (NILP (mask) && found_p && img->mask) |
| 9018 | { | 9069 | { |
| 9019 | XFreePixmap (FRAME_X_DISPLAY (f), img->mask); | 9070 | DeleteObject (img->mask); |
| 9020 | img->mask = NULL; | 9071 | img->mask = NULL; |
| 9021 | } | 9072 | } |
| 9022 | } | 9073 | } |
| @@ -9231,8 +9282,6 @@ forall_images_in_image_cache (f, fn) | |||
| 9231 | W32 support code | 9282 | W32 support code |
| 9232 | ***********************************************************************/ | 9283 | ***********************************************************************/ |
| 9233 | 9284 | ||
| 9234 | #if 0 /* TODO: W32 specific image code. */ | ||
| 9235 | |||
| 9236 | static int x_create_x_image_and_pixmap P_ ((struct frame *, int, int, int, | 9285 | static int x_create_x_image_and_pixmap P_ ((struct frame *, int, int, int, |
| 9237 | XImage **, Pixmap *)); | 9286 | XImage **, Pixmap *)); |
| 9238 | static void x_destroy_x_image P_ ((XImage *)); | 9287 | static void x_destroy_x_image P_ ((XImage *)); |
| @@ -9242,8 +9291,10 @@ static void x_put_x_image P_ ((struct frame *, XImage *, Pixmap, int, int)); | |||
| 9242 | /* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on | 9291 | /* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on |
| 9243 | frame F. Set *XIMG and *PIXMAP to the XImage and Pixmap created. | 9292 | frame F. Set *XIMG and *PIXMAP to the XImage and Pixmap created. |
| 9244 | Set (*XIMG)->data to a raster of WIDTH x HEIGHT pixels allocated | 9293 | Set (*XIMG)->data to a raster of WIDTH x HEIGHT pixels allocated |
| 9245 | via xmalloc. Print error messages via image_error if an error | 9294 | via xmalloc. DEPTH of zero signifies a 24 bit image, otherwise |
| 9246 | occurs. Value is non-zero if successful. */ | 9295 | DEPTH should indicate the bit depth of the image. Print error |
| 9296 | messages via image_error if an error occurs. Value is non-zero if | ||
| 9297 | successful. */ | ||
| 9247 | 9298 | ||
| 9248 | static int | 9299 | static int |
| 9249 | x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) | 9300 | x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) |
| @@ -9252,37 +9303,71 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) | |||
| 9252 | XImage **ximg; | 9303 | XImage **ximg; |
| 9253 | Pixmap *pixmap; | 9304 | Pixmap *pixmap; |
| 9254 | { | 9305 | { |
| 9255 | #if 0 /* TODO: Image support for W32 */ | 9306 | BITMAPINFOHEADER *header; |
| 9256 | Display *display = FRAME_W32_DISPLAY (f); | 9307 | HDC hdc; |
| 9257 | Screen *screen = FRAME_X_SCREEN (f); | 9308 | int scanline_width_bits; |
| 9258 | Window window = FRAME_W32_WINDOW (f); | 9309 | int remainder; |
| 9310 | int palette_colors = 0; | ||
| 9259 | 9311 | ||
| 9260 | xassert (interrupt_input_blocked); | 9312 | if (depth == 0) |
| 9313 | depth = 24; | ||
| 9261 | 9314 | ||
| 9262 | if (depth <= 0) | 9315 | if (depth != 1 && depth != 4 && depth != 8 |
| 9263 | depth = one_w32_display_info.n_cbits; | 9316 | && depth != 16 && depth != 24 && depth != 32) |
| 9264 | *ximg = XCreateImage (display, DefaultVisualOfScreen (screen), | 9317 | { |
| 9265 | depth, ZPixmap, 0, NULL, width, height, | 9318 | image_error ("Invalid image bit depth specified", Qnil, Qnil); |
| 9266 | depth > 16 ? 32 : depth > 8 ? 16 : 8, 0); | 9319 | return 0; |
| 9320 | } | ||
| 9321 | |||
| 9322 | scanline_width_bits = width * depth; | ||
| 9323 | remainder = scanline_width_bits % 32; | ||
| 9324 | |||
| 9325 | if (remainder) | ||
| 9326 | scanline_width_bits += 32 - remainder; | ||
| 9327 | |||
| 9328 | /* Bitmaps with a depth less than 16 need a palette. */ | ||
| 9329 | /* BITMAPINFO structure already contains the first RGBQUAD. */ | ||
| 9330 | if (depth < 16) | ||
| 9331 | palette_colors = 1 << depth - 1; | ||
| 9332 | |||
| 9333 | *ximg = xmalloc (sizeof (XImage) + palette_colors * sizeof (RGBQUAD)); | ||
| 9267 | if (*ximg == NULL) | 9334 | if (*ximg == NULL) |
| 9268 | { | 9335 | { |
| 9269 | image_error ("Unable to allocate X image", Qnil, Qnil); | 9336 | image_error ("Unable to allocate memory for XImage", Qnil, Qnil); |
| 9270 | return 0; | 9337 | return 0; |
| 9271 | } | 9338 | } |
| 9272 | 9339 | ||
| 9273 | /* Allocate image raster. */ | 9340 | header = &((*ximg)->info.bmiHeader); |
| 9274 | (*ximg)->data = (char *) xmalloc ((*ximg)->bytes_per_line * height); | 9341 | bzero (&((*ximg)->info), sizeof (BITMAPINFO)); |
| 9342 | header->biSize = sizeof (*header); | ||
| 9343 | header->biWidth = width; | ||
| 9344 | header->biHeight = -height; /* negative indicates a top-down bitmap. */ | ||
| 9345 | header->biPlanes = 1; | ||
| 9346 | header->biBitCount = depth; | ||
| 9347 | header->biCompression = BI_RGB; | ||
| 9348 | header->biClrUsed = palette_colors; | ||
| 9275 | 9349 | ||
| 9276 | /* Allocate a pixmap of the same size. */ | 9350 | hdc = get_frame_dc (f); |
| 9277 | *pixmap = XCreatePixmap (display, window, width, height, depth); | 9351 | |
| 9278 | if (*pixmap == 0) | 9352 | /* Create a DIBSection and raster array for the bitmap, |
| 9353 | and store its handle in *pixmap. */ | ||
| 9354 | *pixmap = CreateDIBSection (hdc, &((*ximg)->info), DIB_RGB_COLORS, | ||
| 9355 | &((*ximg)->data), NULL, 0); | ||
| 9356 | |||
| 9357 | /* Realize display palette and garbage all frames. */ | ||
| 9358 | release_frame_dc (f, hdc); | ||
| 9359 | |||
| 9360 | if (*pixmap == NULL) | ||
| 9279 | { | 9361 | { |
| 9362 | DWORD err = GetLastError(); | ||
| 9363 | Lisp_Object errcode; | ||
| 9364 | /* All system errors are < 10000, so the following is safe. */ | ||
| 9365 | XSETINT (errcode, (int) err); | ||
| 9366 | image_error ("Unable to create bitmap, error code %d", errcode, Qnil); | ||
| 9280 | x_destroy_x_image (*ximg); | 9367 | x_destroy_x_image (*ximg); |
| 9281 | *ximg = NULL; | ||
| 9282 | image_error ("Unable to create X pixmap", Qnil, Qnil); | ||
| 9283 | return 0; | 9368 | return 0; |
| 9284 | } | 9369 | } |
| 9285 | #endif | 9370 | |
| 9286 | return 1; | 9371 | return 1; |
| 9287 | } | 9372 | } |
| 9288 | 9373 | ||
| @@ -9296,9 +9381,9 @@ x_destroy_x_image (ximg) | |||
| 9296 | xassert (interrupt_input_blocked); | 9381 | xassert (interrupt_input_blocked); |
| 9297 | if (ximg) | 9382 | if (ximg) |
| 9298 | { | 9383 | { |
| 9299 | xfree (ximg->data); | 9384 | /* Data will be freed by DestroyObject. */ |
| 9300 | ximg->data = NULL; | 9385 | ximg->data = NULL; |
| 9301 | XDestroyImage (ximg); | 9386 | xfree (ximg); |
| 9302 | } | 9387 | } |
| 9303 | } | 9388 | } |
| 9304 | 9389 | ||
| @@ -9312,15 +9397,16 @@ x_put_x_image (f, ximg, pixmap, width, height) | |||
| 9312 | XImage *ximg; | 9397 | XImage *ximg; |
| 9313 | Pixmap pixmap; | 9398 | Pixmap pixmap; |
| 9314 | { | 9399 | { |
| 9400 | |||
| 9401 | #if TODO /* W32 specific image code. */ | ||
| 9315 | GC gc; | 9402 | GC gc; |
| 9316 | 9403 | ||
| 9317 | xassert (interrupt_input_blocked); | 9404 | xassert (interrupt_input_blocked); |
| 9318 | gc = XCreateGC (NULL, pixmap, 0, NULL); | 9405 | gc = XCreateGC (NULL, pixmap, 0, NULL); |
| 9319 | XPutImage (NULL, pixmap, gc, ximg, 0, 0, 0, 0, width, height); | 9406 | XPutImage (NULL, pixmap, gc, ximg, 0, 0, 0, 0, width, height); |
| 9320 | XFreeGC (NULL, gc); | 9407 | XFreeGC (NULL, gc); |
| 9321 | } | ||
| 9322 | |||
| 9323 | #endif | 9408 | #endif |
| 9409 | } | ||
| 9324 | 9410 | ||
| 9325 | 9411 | ||
| 9326 | /*********************************************************************** | 9412 | /*********************************************************************** |
| @@ -9844,6 +9930,8 @@ xbm_load_image (f, img, contents, end) | |||
| 9844 | if (rc) | 9930 | if (rc) |
| 9845 | { | 9931 | { |
| 9846 | int depth = one_w32_display_info.n_cbits; | 9932 | int depth = one_w32_display_info.n_cbits; |
| 9933 | int planes = one_w32_display_info.n_planes; | ||
| 9934 | |||
| 9847 | unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); | 9935 | unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); |
| 9848 | unsigned long background = FRAME_BACKGROUND_PIXEL (f); | 9936 | unsigned long background = FRAME_BACKGROUND_PIXEL (f); |
| 9849 | Lisp_Object value; | 9937 | Lisp_Object value; |
| @@ -9861,16 +9949,9 @@ xbm_load_image (f, img, contents, end) | |||
| 9861 | img->background = background; | 9949 | img->background = background; |
| 9862 | img->background_valid = 1; | 9950 | img->background_valid = 1; |
| 9863 | } | 9951 | } |
| 9864 | |||
| 9865 | #if 0 /* TODO : Port image display to W32 */ | ||
| 9866 | img->pixmap | 9952 | img->pixmap |
| 9867 | = XCreatePixmapFromBitmapData (FRAME_W32_DISPLAY (f), | 9953 | = CreateBitmap (img->width, img->height, planes, depth, data); |
| 9868 | FRAME_W32_WINDOW (f), | 9954 | |
| 9869 | data, | ||
| 9870 | img->width, img->height, | ||
| 9871 | foreground, background, | ||
| 9872 | depth); | ||
| 9873 | #endif | ||
| 9874 | xfree (data); | 9955 | xfree (data); |
| 9875 | 9956 | ||
| 9876 | if (img->pixmap == 0) | 9957 | if (img->pixmap == 0) |
| @@ -10478,13 +10559,14 @@ colors_in_color_table (n) | |||
| 10478 | #endif /* TODO */ | 10559 | #endif /* TODO */ |
| 10479 | 10560 | ||
| 10480 | 10561 | ||
| 10562 | #ifdef HAVE_IMAGES /* TODO */ | ||
| 10481 | /*********************************************************************** | 10563 | /*********************************************************************** |
| 10482 | Algorithms | 10564 | Algorithms |
| 10483 | ***********************************************************************/ | 10565 | ***********************************************************************/ |
| 10484 | #if 0 /* TODO: image support. */ | ||
| 10485 | static XColor *x_to_xcolors P_ ((struct frame *, struct image *, int)); | 10566 | static XColor *x_to_xcolors P_ ((struct frame *, struct image *, int)); |
| 10486 | static void x_from_xcolors P_ ((struct frame *, struct image *, XColor *)); | 10567 | static void x_from_xcolors P_ ((struct frame *, struct image *, XColor *)); |
| 10487 | static void x_detect_edges P_ ((struct frame *, struct image *, int[9], int)); | 10568 | static void x_detect_edges P_ ((struct frame *, struct image *, int[9], int)); |
| 10569 | static void XPutPixel (XImage *, int, int, COLORREF); | ||
| 10488 | 10570 | ||
| 10489 | /* Non-zero means draw a cross on images having `:conversion | 10571 | /* Non-zero means draw a cross on images having `:conversion |
| 10490 | disabled'. */ | 10572 | disabled'. */ |
| @@ -10531,7 +10613,7 @@ x_to_xcolors (f, img, rgb_p) | |||
| 10531 | XImage *ximg; | 10613 | XImage *ximg; |
| 10532 | 10614 | ||
| 10533 | colors = (XColor *) xmalloc (img->width * img->height * sizeof *colors); | 10615 | colors = (XColor *) xmalloc (img->width * img->height * sizeof *colors); |
| 10534 | 10616 | #if 0 /* TODO: implement image colors. */ | |
| 10535 | /* Get the X image IMG->pixmap. */ | 10617 | /* Get the X image IMG->pixmap. */ |
| 10536 | ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap, | 10618 | ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap, |
| 10537 | 0, 0, img->width, img->height, ~0, ZPixmap); | 10619 | 0, 0, img->width, img->height, ~0, ZPixmap); |
| @@ -10551,9 +10633,37 @@ x_to_xcolors (f, img, rgb_p) | |||
| 10551 | } | 10633 | } |
| 10552 | 10634 | ||
| 10553 | XDestroyImage (ximg); | 10635 | XDestroyImage (ximg); |
| 10636 | #endif | ||
| 10554 | return colors; | 10637 | return colors; |
| 10555 | } | 10638 | } |
| 10556 | 10639 | ||
| 10640 | /* Put a pixel of COLOR at position X, Y in XIMG. XIMG must have been | ||
| 10641 | created with CreateDIBSection, with the pointer to the bit values | ||
| 10642 | stored in ximg->data. */ | ||
| 10643 | |||
| 10644 | static void XPutPixel (ximg, x, y, color) | ||
| 10645 | XImage * ximg; | ||
| 10646 | int x, y; | ||
| 10647 | COLORREF color; | ||
| 10648 | { | ||
| 10649 | int width = ximg->info.bmiHeader.biWidth; | ||
| 10650 | int height = ximg->info.bmiHeader.biHeight; | ||
| 10651 | int rowbytes = width * 3; | ||
| 10652 | unsigned char * pixel; | ||
| 10653 | |||
| 10654 | /* Don't support putting pixels in images with palettes. */ | ||
| 10655 | xassert (ximg->info.bmiHeader.biBitCount == 24); | ||
| 10656 | |||
| 10657 | /* Ensure scanlines are aligned on 4 byte boundaries. */ | ||
| 10658 | if (rowbytes % 4) | ||
| 10659 | rowbytes += 4 - (rowbytes % 4); | ||
| 10660 | |||
| 10661 | pixel = ximg->data + y * rowbytes + x * 3; | ||
| 10662 | *pixel = 255 - GetRValue (color); | ||
| 10663 | *(pixel + 1) = 255 - GetGValue (color); | ||
| 10664 | *(pixel + 2) = 255 - GetBValue (color); | ||
| 10665 | } | ||
| 10666 | |||
| 10557 | 10667 | ||
| 10558 | /* Create IMG->pixmap from an array COLORS of XColor structures, whose | 10668 | /* Create IMG->pixmap from an array COLORS of XColor structures, whose |
| 10559 | RGB members are set. F is the frame on which this all happens. | 10669 | RGB members are set. F is the frame on which this all happens. |
| @@ -10569,9 +10679,9 @@ x_from_xcolors (f, img, colors) | |||
| 10569 | XImage *oimg; | 10679 | XImage *oimg; |
| 10570 | Pixmap pixmap; | 10680 | Pixmap pixmap; |
| 10571 | XColor *p; | 10681 | XColor *p; |
| 10572 | 10682 | #if 0 /* TODO: color tables. */ | |
| 10573 | init_color_table (); | 10683 | init_color_table (); |
| 10574 | 10684 | #endif | |
| 10575 | x_create_x_image_and_pixmap (f, img->width, img->height, 0, | 10685 | x_create_x_image_and_pixmap (f, img->width, img->height, 0, |
| 10576 | &oimg, &pixmap); | 10686 | &oimg, &pixmap); |
| 10577 | p = colors; | 10687 | p = colors; |
| @@ -10579,7 +10689,11 @@ x_from_xcolors (f, img, colors) | |||
| 10579 | for (x = 0; x < img->width; ++x, ++p) | 10689 | for (x = 0; x < img->width; ++x, ++p) |
| 10580 | { | 10690 | { |
| 10581 | unsigned long pixel; | 10691 | unsigned long pixel; |
| 10692 | #if 0 /* TODO: color tables. */ | ||
| 10582 | pixel = lookup_rgb_color (f, p->red, p->green, p->blue); | 10693 | pixel = lookup_rgb_color (f, p->red, p->green, p->blue); |
| 10694 | #else | ||
| 10695 | pixel = PALETTERGB (p->red, p->green, p->blue); | ||
| 10696 | #endif | ||
| 10583 | XPutPixel (oimg, x, y, pixel); | 10697 | XPutPixel (oimg, x, y, pixel); |
| 10584 | } | 10698 | } |
| 10585 | 10699 | ||
| @@ -10589,8 +10703,10 @@ x_from_xcolors (f, img, colors) | |||
| 10589 | x_put_x_image (f, oimg, pixmap, img->width, img->height); | 10703 | x_put_x_image (f, oimg, pixmap, img->width, img->height); |
| 10590 | x_destroy_x_image (oimg); | 10704 | x_destroy_x_image (oimg); |
| 10591 | img->pixmap = pixmap; | 10705 | img->pixmap = pixmap; |
| 10706 | #if 0 /* TODO: color tables. */ | ||
| 10592 | img->colors = colors_in_color_table (&img->ncolors); | 10707 | img->colors = colors_in_color_table (&img->ncolors); |
| 10593 | free_color_table (); | 10708 | free_color_table (); |
| 10709 | #endif | ||
| 10594 | } | 10710 | } |
| 10595 | 10711 | ||
| 10596 | 10712 | ||
| @@ -10741,9 +10857,9 @@ x_disable_image (f, img) | |||
| 10741 | struct frame *f; | 10857 | struct frame *f; |
| 10742 | struct image *img; | 10858 | struct image *img; |
| 10743 | { | 10859 | { |
| 10744 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 10860 | struct w32_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 10745 | 10861 | ||
| 10746 | if (dpyinfo->n_planes >= 2) | 10862 | if (dpyinfo->n_planes * dpyinfo->n_cbits >= 2) |
| 10747 | { | 10863 | { |
| 10748 | /* Color (or grayscale). Convert to gray, and equalize. Just | 10864 | /* Color (or grayscale). Convert to gray, and equalize. Just |
| 10749 | drawing such images with a stipple can look very odd, so | 10865 | drawing such images with a stipple can look very odd, so |
| @@ -10767,8 +10883,9 @@ x_disable_image (f, img) | |||
| 10767 | 10883 | ||
| 10768 | /* Draw a cross over the disabled image, if we must or if we | 10884 | /* Draw a cross over the disabled image, if we must or if we |
| 10769 | should. */ | 10885 | should. */ |
| 10770 | if (dpyinfo->n_planes < 2 || cross_disabled_images) | 10886 | if (dpyinfo->n_planes * dpyinfo->n_cbits < 2 || cross_disabled_images) |
| 10771 | { | 10887 | { |
| 10888 | #if 0 /* TODO: full image support */ | ||
| 10772 | Display *dpy = FRAME_X_DISPLAY (f); | 10889 | Display *dpy = FRAME_X_DISPLAY (f); |
| 10773 | GC gc; | 10890 | GC gc; |
| 10774 | 10891 | ||
| @@ -10790,6 +10907,7 @@ x_disable_image (f, img) | |||
| 10790 | img->width - 1, 0); | 10907 | img->width - 1, 0); |
| 10791 | XFreeGC (dpy, gc); | 10908 | XFreeGC (dpy, gc); |
| 10792 | } | 10909 | } |
| 10910 | #endif | ||
| 10793 | } | 10911 | } |
| 10794 | } | 10912 | } |
| 10795 | 10913 | ||
| @@ -10807,6 +10925,7 @@ x_build_heuristic_mask (f, img, how) | |||
| 10807 | struct image *img; | 10925 | struct image *img; |
| 10808 | Lisp_Object how; | 10926 | Lisp_Object how; |
| 10809 | { | 10927 | { |
| 10928 | #if 0 /* TODO: full image support. */ | ||
| 10810 | Display *dpy = FRAME_W32_DISPLAY (f); | 10929 | Display *dpy = FRAME_W32_DISPLAY (f); |
| 10811 | XImage *ximg, *mask_img; | 10930 | XImage *ximg, *mask_img; |
| 10812 | int x, y, rc, use_img_background; | 10931 | int x, y, rc, use_img_background; |
| @@ -10870,9 +10989,11 @@ x_build_heuristic_mask (f, img, how) | |||
| 10870 | XDestroyImage (ximg); | 10989 | XDestroyImage (ximg); |
| 10871 | 10990 | ||
| 10872 | return 1; | 10991 | return 1; |
| 10992 | #else | ||
| 10993 | return 0; | ||
| 10994 | #endif | ||
| 10873 | } | 10995 | } |
| 10874 | #endif /* TODO */ | 10996 | #endif |
| 10875 | |||
| 10876 | 10997 | ||
| 10877 | /*********************************************************************** | 10998 | /*********************************************************************** |
| 10878 | PBM (mono, gray, color) | 10999 | PBM (mono, gray, color) |
| @@ -11137,12 +11258,13 @@ pbm_load (f, img) | |||
| 11137 | || (type != PBM_MONO && max_color_idx < 0)) | 11258 | || (type != PBM_MONO && max_color_idx < 0)) |
| 11138 | goto error; | 11259 | goto error; |
| 11139 | 11260 | ||
| 11140 | if (!x_create_x_image_and_pixmap (f, width, height, 0, | 11261 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) |
| 11141 | &ximg, &img->pixmap)) | ||
| 11142 | goto error; | 11262 | goto error; |
| 11143 | 11263 | ||
| 11264 | #if 0 /* TODO: color tables. */ | ||
| 11144 | /* Initialize the color hash table. */ | 11265 | /* Initialize the color hash table. */ |
| 11145 | init_color_table (); | 11266 | init_color_table (); |
| 11267 | #endif | ||
| 11146 | 11268 | ||
| 11147 | if (type == PBM_MONO) | 11269 | if (type == PBM_MONO) |
| 11148 | { | 11270 | { |
| @@ -11207,28 +11329,32 @@ pbm_load (f, img) | |||
| 11207 | 11329 | ||
| 11208 | if (r < 0 || g < 0 || b < 0) | 11330 | if (r < 0 || g < 0 || b < 0) |
| 11209 | { | 11331 | { |
| 11210 | xfree (ximg->data); | 11332 | x_destroy_x_image (ximg); |
| 11211 | ximg->data = NULL; | ||
| 11212 | XDestroyImage (ximg); | ||
| 11213 | image_error ("Invalid pixel value in image `%s'", | 11333 | image_error ("Invalid pixel value in image `%s'", |
| 11214 | img->spec, Qnil); | 11334 | img->spec, Qnil); |
| 11215 | goto error; | 11335 | goto error; |
| 11216 | } | 11336 | } |
| 11217 | 11337 | ||
| 11218 | /* RGB values are now in the range 0..max_color_idx. | 11338 | /* RGB values are now in the range 0..max_color_idx. |
| 11219 | Scale this to the range 0..0xffff supported by X. */ | 11339 | Scale this to the range 0..0xff supported by W32. */ |
| 11220 | r = (double) r * 65535 / max_color_idx; | 11340 | r = (int) ((double) r * 255 / max_color_idx); |
| 11221 | g = (double) g * 65535 / max_color_idx; | 11341 | g = (int) ((double) g * 255 / max_color_idx); |
| 11222 | b = (double) b * 65535 / max_color_idx; | 11342 | b = (int) ((double) b * 255 / max_color_idx); |
| 11223 | XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b)); | 11343 | XPutPixel (ximg, x, y, |
| 11344 | #if 0 /* TODO: color tables. */ | ||
| 11345 | lookup_rgb_color (f, r, g, b)); | ||
| 11346 | #else | ||
| 11347 | PALETTERGB (r, g, b)); | ||
| 11348 | #endif | ||
| 11224 | } | 11349 | } |
| 11225 | } | 11350 | } |
| 11226 | 11351 | ||
| 11352 | #if 0 /* TODO: color tables. */ | ||
| 11227 | /* Store in IMG->colors the colors allocated for the image, and | 11353 | /* Store in IMG->colors the colors allocated for the image, and |
| 11228 | free the color table. */ | 11354 | free the color table. */ |
| 11229 | img->colors = colors_in_color_table (&img->ncolors); | 11355 | img->colors = colors_in_color_table (&img->ncolors); |
| 11230 | free_color_table (); | 11356 | free_color_table (); |
| 11231 | 11357 | #endif | |
| 11232 | /* Maybe fill in the background field while we have ximg handy. */ | 11358 | /* Maybe fill in the background field while we have ximg handy. */ |
| 11233 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | 11359 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) |
| 11234 | IMAGE_BACKGROUND (img, f, ximg); | 11360 | IMAGE_BACKGROUND (img, f, ximg); |
| @@ -14550,14 +14676,16 @@ If the underlying system call fails, value is nil. */) | |||
| 14550 | 14676 | ||
| 14551 | if (pfn_GetDiskFreeSpaceEx) | 14677 | if (pfn_GetDiskFreeSpaceEx) |
| 14552 | { | 14678 | { |
| 14679 | /* Unsigned large integers cannot be cast to double, so | ||
| 14680 | use signed ones instead. */ | ||
| 14553 | LARGE_INTEGER availbytes; | 14681 | LARGE_INTEGER availbytes; |
| 14554 | LARGE_INTEGER freebytes; | 14682 | LARGE_INTEGER freebytes; |
| 14555 | LARGE_INTEGER totalbytes; | 14683 | LARGE_INTEGER totalbytes; |
| 14556 | 14684 | ||
| 14557 | if (pfn_GetDiskFreeSpaceEx(rootname, | 14685 | if (pfn_GetDiskFreeSpaceEx(rootname, |
| 14558 | &availbytes, | 14686 | (ULARGE_INTEGER *)&availbytes, |
| 14559 | &totalbytes, | 14687 | (ULARGE_INTEGER *)&totalbytes, |
| 14560 | &freebytes)) | 14688 | (ULARGE_INTEGER *)&freebytes)) |
| 14561 | value = list3 (make_float ((double) totalbytes.QuadPart), | 14689 | value = list3 (make_float ((double) totalbytes.QuadPart), |
| 14562 | make_float ((double) freebytes.QuadPart), | 14690 | make_float ((double) freebytes.QuadPart), |
| 14563 | make_float ((double) availbytes.QuadPart)); | 14691 | make_float ((double) availbytes.QuadPart)); |
| @@ -15106,7 +15234,7 @@ versions of Windows) characters. */); | |||
| 15106 | set_frame_fontset_func = x_set_font; | 15234 | set_frame_fontset_func = x_set_font; |
| 15107 | check_window_system_func = check_w32; | 15235 | check_window_system_func = check_w32; |
| 15108 | 15236 | ||
| 15109 | #if 0 /* TODO Image support for W32 */ | 15237 | #ifdef IMAGES |
| 15110 | /* Images. */ | 15238 | /* Images. */ |
| 15111 | Qxbm = intern ("xbm"); | 15239 | Qxbm = intern ("xbm"); |
| 15112 | staticpro (&Qxbm); | 15240 | staticpro (&Qxbm); |
| @@ -15126,6 +15254,7 @@ versions of Windows) characters. */); | |||
| 15126 | staticpro (&QCrelief); | 15254 | staticpro (&QCrelief); |
| 15127 | Qpostscript = intern ("postscript"); | 15255 | Qpostscript = intern ("postscript"); |
| 15128 | staticpro (&Qpostscript); | 15256 | staticpro (&Qpostscript); |
| 15257 | #if 0 /* TODO: These need entries at top of file. */ | ||
| 15129 | QCloader = intern (":loader"); | 15258 | QCloader = intern (":loader"); |
| 15130 | staticpro (&QCloader); | 15259 | staticpro (&QCloader); |
| 15131 | QCbounding_box = intern (":bounding-box"); | 15260 | QCbounding_box = intern (":bounding-box"); |
| @@ -15134,10 +15263,12 @@ versions of Windows) characters. */); | |||
| 15134 | staticpro (&QCpt_width); | 15263 | staticpro (&QCpt_width); |
| 15135 | QCpt_height = intern (":pt-height"); | 15264 | QCpt_height = intern (":pt-height"); |
| 15136 | staticpro (&QCpt_height); | 15265 | staticpro (&QCpt_height); |
| 15266 | #endif | ||
| 15137 | QCindex = intern (":index"); | 15267 | QCindex = intern (":index"); |
| 15138 | staticpro (&QCindex); | 15268 | staticpro (&QCindex); |
| 15139 | Qpbm = intern ("pbm"); | 15269 | Qpbm = intern ("pbm"); |
| 15140 | staticpro (&Qpbm); | 15270 | staticpro (&Qpbm); |
| 15271 | #endif | ||
| 15141 | 15272 | ||
| 15142 | #if HAVE_XPM | 15273 | #if HAVE_XPM |
| 15143 | Qxpm = intern ("xpm"); | 15274 | Qxpm = intern ("xpm"); |
| @@ -15164,13 +15295,16 @@ versions of Windows) characters. */); | |||
| 15164 | staticpro (&Qpng); | 15295 | staticpro (&Qpng); |
| 15165 | #endif | 15296 | #endif |
| 15166 | 15297 | ||
| 15298 | #ifdef HAVE_IMAGES | ||
| 15167 | defsubr (&Sclear_image_cache); | 15299 | defsubr (&Sclear_image_cache); |
| 15300 | defsubr (&Simage_size); | ||
| 15301 | defsubr (&Simage_mask_p); | ||
| 15302 | #endif | ||
| 15168 | 15303 | ||
| 15169 | #if GLYPH_DEBUG | 15304 | #if GLYPH_DEBUG |
| 15170 | defsubr (&Simagep); | 15305 | defsubr (&Simagep); |
| 15171 | defsubr (&Slookup_image); | 15306 | defsubr (&Slookup_image); |
| 15172 | #endif | 15307 | #endif |
| 15173 | #endif /* TODO */ | ||
| 15174 | 15308 | ||
| 15175 | hourglass_atimer = NULL; | 15309 | hourglass_atimer = NULL; |
| 15176 | hourglass_shown_p = 0; | 15310 | hourglass_shown_p = 0; |
| @@ -15194,10 +15328,14 @@ init_xfns () | |||
| 15194 | image_types = NULL; | 15328 | image_types = NULL; |
| 15195 | Vimage_types = Qnil; | 15329 | Vimage_types = Qnil; |
| 15196 | 15330 | ||
| 15331 | #if HAVE_PBM | ||
| 15332 | define_image_type (&pbm_type); | ||
| 15333 | #endif | ||
| 15334 | |||
| 15197 | #if 0 /* TODO : Image support for W32 */ | 15335 | #if 0 /* TODO : Image support for W32 */ |
| 15198 | define_image_type (&xbm_type); | 15336 | define_image_type (&xbm_type); |
| 15199 | define_image_type (&gs_type); | 15337 | define_image_type (&gs_type); |
| 15200 | define_image_type (&pbm_type); | 15338 | #endif |
| 15201 | 15339 | ||
| 15202 | #if HAVE_XPM | 15340 | #if HAVE_XPM |
| 15203 | define_image_type (&xpm_type); | 15341 | define_image_type (&xpm_type); |
| @@ -15218,7 +15356,6 @@ init_xfns () | |||
| 15218 | #if HAVE_PNG | 15356 | #if HAVE_PNG |
| 15219 | define_image_type (&png_type); | 15357 | define_image_type (&png_type); |
| 15220 | #endif | 15358 | #endif |
| 15221 | #endif /* TODO */ | ||
| 15222 | } | 15359 | } |
| 15223 | 15360 | ||
| 15224 | #undef abort | 15361 | #undef abort |