aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c825
1 files changed, 281 insertions, 544 deletions
diff --git a/src/image.c b/src/image.c
index bf594987eb8..57b405f6db9 100644
--- a/src/image.c
+++ b/src/image.c
@@ -132,17 +132,17 @@ static unsigned long *colors_in_color_table (int *n);
132#ifdef HAVE_NS 132#ifdef HAVE_NS
133/* Use with images created by ns_image_for_XPM. */ 133/* Use with images created by ns_image_for_XPM. */
134static unsigned long 134static unsigned long
135XGetPixel (XImagePtr ximage, int x, int y) 135XGetPixel (Emacs_Pix_Container image, int x, int y)
136{ 136{
137 return ns_get_pixel (ximage, x, y); 137 return ns_get_pixel (image, x, y);
138} 138}
139 139
140/* Use with images created by ns_image_for_XPM; alpha set to 1; 140/* Use with images created by ns_image_for_XPM; alpha set to 1;
141 pixel is assumed to be in RGB form. */ 141 pixel is assumed to be in RGB form. */
142static void 142static void
143XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel) 143XPutPixel (Emacs_Pix_Container image, int x, int y, unsigned long pixel)
144{ 144{
145 ns_put_pixel (ximage, x, y, pixel); 145 ns_put_pixel (image, x, y, pixel);
146} 146}
147#endif /* HAVE_NS */ 147#endif /* HAVE_NS */
148 148
@@ -228,7 +228,7 @@ image_create_bitmap_from_data (struct frame *f, char *bits,
228 228
229#ifdef HAVE_NTGUI 229#ifdef HAVE_NTGUI
230 Lisp_Object frame UNINIT; /* The value is not used. */ 230 Lisp_Object frame UNINIT; /* The value is not used. */
231 Pixmap bitmap; 231 Emacs_Pixmap bitmap;
232 bitmap = CreateBitmap (width, height, 232 bitmap = CreateBitmap (width, height,
233 FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes, 233 FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes,
234 FRAME_DISPLAY_INFO (XFRAME (frame))->n_cbits, 234 FRAME_DISPLAY_INFO (XFRAME (frame))->n_cbits,
@@ -412,17 +412,19 @@ typedef void Picture;
412#endif 412#endif
413 413
414static bool image_create_x_image_and_pixmap_1 (struct frame *, int, int, int, 414static bool image_create_x_image_and_pixmap_1 (struct frame *, int, int, int,
415 XImagePtr *, Pixmap *, Picture *); 415 Emacs_Pix_Container *,
416static void image_destroy_x_image (XImagePtr ximg); 416 Emacs_Pixmap *, Picture *);
417static void image_destroy_x_image (Emacs_Pix_Container);
417 418
418#ifdef HAVE_NTGUI 419#ifdef HAVE_NTGUI
419static XImagePtr_or_DC image_get_x_image_or_dc (struct frame *, struct image *, 420static HDC image_get_x_image_or_dc (struct frame *, struct image *,
420 bool, HGDIOBJ *); 421 bool, HGDIOBJ *);
421static void image_unget_x_image_or_dc (struct image *, bool, XImagePtr_or_DC, 422static void image_unget_x_image_or_dc (struct image *, bool,
422 HGDIOBJ); 423 HDC, HGDIOBJ);
423#else 424#else
424static XImagePtr image_get_x_image (struct frame *, struct image *, bool); 425static Emacs_Pix_Container image_get_x_image (struct frame *, struct image *,
425static void image_unget_x_image (struct image *, bool, XImagePtr); 426 bool);
427static void image_unget_x_image (struct image *, bool, Emacs_Pix_Container);
426#define image_get_x_image_or_dc(f, img, mask_p, dummy) \ 428#define image_get_x_image_or_dc(f, img, mask_p, dummy) \
427 image_get_x_image (f, img, mask_p) 429 image_get_x_image (f, img, mask_p)
428#define image_unget_x_image_or_dc(img, mask_p, ximg, dummy) \ 430#define image_unget_x_image_or_dc(img, mask_p, ximg, dummy) \
@@ -436,7 +438,7 @@ static void image_sync_to_pixmaps (struct frame *, struct image *);
436/* Useful functions defined in the section 438/* Useful functions defined in the section
437 `Image type independent image structures' below. */ 439 `Image type independent image structures' below. */
438 440
439static unsigned long four_corners_best (XImagePtr ximg, 441static unsigned long four_corners_best (XImage *ximg,
440 int *corners, 442 int *corners,
441 unsigned long width, 443 unsigned long width,
442 unsigned long height); 444 unsigned long height);
@@ -449,7 +451,7 @@ void
449x_create_bitmap_mask (struct frame *f, ptrdiff_t id) 451x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
450{ 452{
451 Pixmap pixmap, mask; 453 Pixmap pixmap, mask;
452 XImagePtr ximg, mask_img; 454 XImage *ximg, *mask_img;
453 unsigned long width, height; 455 unsigned long width, height;
454 bool result; 456 bool result;
455 unsigned long bg; 457 unsigned long bg;
@@ -548,82 +550,29 @@ struct image_type
548 /* Free resources of image IMG which is used on frame F. */ 550 /* Free resources of image IMG which is used on frame F. */
549 void (*free) (struct frame *f, struct image *img); 551 void (*free) (struct frame *f, struct image *img);
550 552
553#ifdef WINDOWSNT
551 /* Initialization function (used for dynamic loading of image 554 /* Initialization function (used for dynamic loading of image
552 libraries on Windows), or NULL if none. */ 555 libraries on Windows), or NULL if none. */
553 bool (*init) (void); 556 bool (*init) (void);
554 557 /* An initializer for the init field. */
555 /* Next in list of all supported image types. */ 558# define IMAGE_TYPE_INIT(f) f
556 struct image_type *next; 559#else
560# define IMAGE_TYPE_INIT(f)
561#endif
557}; 562};
558 563
559/* List of supported image types. Use define_image_type to add new
560 types. Use lookup_image_type to find a type for a given symbol. */
561
562static struct image_type *image_types;
563
564/* Forward function prototypes. */ 564/* Forward function prototypes. */
565 565
566static struct image_type *lookup_image_type (Lisp_Object); 566static struct image_type const *lookup_image_type (Lisp_Object);
567static void image_laplace (struct frame *, struct image *); 567static void image_laplace (struct frame *, struct image *);
568static void image_emboss (struct frame *, struct image *); 568static void image_emboss (struct frame *, struct image *);
569static void image_build_heuristic_mask (struct frame *, struct image *, 569static void image_build_heuristic_mask (struct frame *, struct image *,
570 Lisp_Object); 570 Lisp_Object);
571#ifdef WINDOWSNT
572#define CACHE_IMAGE_TYPE(type, status) \
573 do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0)
574#else
575#define CACHE_IMAGE_TYPE(type, status)
576#endif
577
578#define ADD_IMAGE_TYPE(type) \
579 do { Vimage_types = Fcons (type, Vimage_types); } while (0)
580
581/* Define a new image type from TYPE. This adds a copy of TYPE to
582 image_types and caches the loading status of TYPE. */
583 571
584static struct image_type * 572static void
585define_image_type (struct image_type *type) 573add_image_type (Lisp_Object type)
586{ 574{
587 struct image_type *p = NULL; 575 Vimage_types = Fcons (type, Vimage_types);
588 int new_type = type->type;
589 bool type_valid = true;
590
591 block_input ();
592
593 for (p = image_types; p; p = p->next)
594 if (p->type == new_type)
595 goto done;
596
597 if (type->init)
598 {
599#if defined HAVE_NTGUI && defined WINDOWSNT
600 /* If we failed to load the library before, don't try again. */
601 Lisp_Object tested = Fassq (builtin_lisp_symbol (new_type),
602 Vlibrary_cache);
603 if (CONSP (tested) && NILP (XCDR (tested)))
604 type_valid = false;
605 else
606#endif
607 {
608 type_valid = type->init ();
609 CACHE_IMAGE_TYPE (builtin_lisp_symbol (new_type),
610 type_valid ? Qt : Qnil);
611 }
612 }
613
614 if (type_valid)
615 {
616 /* Make a copy of TYPE to avoid a bus error in a dumped Emacs.
617 The initialized data segment is read-only. */
618 p = xmalloc (sizeof *p);
619 *p = *type;
620 p->next = image_types;
621 image_types = p;
622 }
623
624 done:
625 unblock_input ();
626 return p;
627} 576}
628 577
629 578
@@ -637,29 +586,24 @@ define_image_type (struct image_type *type)
637bool 586bool
638valid_image_p (Lisp_Object object) 587valid_image_p (Lisp_Object object)
639{ 588{
640 bool valid_p = 0;
641
642 if (IMAGEP (object)) 589 if (IMAGEP (object))
643 { 590 {
644 Lisp_Object tem; 591 Lisp_Object tail = XCDR (object);
645 592 FOR_EACH_TAIL_SAFE (tail)
646 for (tem = XCDR (object); CONSP (tem); tem = XCDR (tem)) 593 if (EQ (XCAR (tail), QCtype))
647 if (EQ (XCAR (tem), QCtype))
648 { 594 {
649 tem = XCDR (tem); 595 tail = XCDR (tail);
650 if (CONSP (tem) && SYMBOLP (XCAR (tem))) 596 if (CONSP (tail))
651 { 597 {
652 struct image_type *type; 598 struct image_type const *type = lookup_image_type (XCAR (tail));
653 type = lookup_image_type (XCAR (tem));
654 if (type) 599 if (type)
655 valid_p = type->valid_p (object); 600 return type->valid_p (object);
656 } 601 }
657
658 break; 602 break;
659 } 603 }
660 } 604 }
661 605
662 return valid_p; 606 return false;
663} 607}
664 608
665 609
@@ -1134,10 +1078,10 @@ image_ascent (struct image *img, struct face *face, struct glyph_slice *slice)
1134 1078
1135#ifdef USE_CAIRO 1079#ifdef USE_CAIRO
1136static uint32_t 1080static uint32_t
1137xcolor_to_argb32 (XColor xc) 1081emacs_color_to_argb32 (Emacs_Color *ec)
1138{ 1082{
1139 return ((0xffu << 24) | ((xc.red / 256) << 16) 1083 return ((0xffu << 24) | ((ec->red / 256) << 16)
1140 | ((xc.green / 256) << 8) | (xc.blue / 256)); 1084 | ((ec->green / 256) << 8) | (ec->blue / 256));
1141} 1085}
1142 1086
1143static uint32_t 1087static uint32_t
@@ -1145,11 +1089,11 @@ get_spec_bg_or_alpha_as_argb (struct image *img,
1145 struct frame *f) 1089 struct frame *f)
1146{ 1090{
1147 uint32_t bgcolor = 0; 1091 uint32_t bgcolor = 0;
1148 XColor xbgcolor; 1092 Emacs_Color xbgcolor;
1149 Lisp_Object bg = image_spec_value (img->spec, QCbackground, NULL); 1093 Lisp_Object bg = image_spec_value (img->spec, QCbackground, NULL);
1150 1094
1151 if (STRINGP (bg) && x_parse_color (f, SSDATA (bg), &xbgcolor)) 1095 if (STRINGP (bg) && x_parse_color (f, SSDATA (bg), &xbgcolor))
1152 bgcolor = xcolor_to_argb32 (xbgcolor); 1096 bgcolor = emacs_color_to_argb32 (&xbgcolor);
1153 1097
1154 return bgcolor; 1098 return bgcolor;
1155} 1099}
@@ -1179,10 +1123,10 @@ set_cairo_image_surface (struct image *img, cairo_surface_t *surface)
1179/* Image background colors. */ 1123/* Image background colors. */
1180 1124
1181/* Find the "best" corner color of a bitmap. 1125/* Find the "best" corner color of a bitmap.
1182 On W32, XIMG is assumed to a device context with the bitmap selected. */ 1126 On W32, PIMG is assumed to a device context with the bitmap selected. */
1183 1127
1184static RGB_PIXEL_COLOR 1128static RGB_PIXEL_COLOR
1185four_corners_best (XImagePtr_or_DC ximg, int *corners, 1129four_corners_best (Emacs_Pix_Context pimg, int *corners,
1186 unsigned long width, unsigned long height) 1130 unsigned long width, unsigned long height)
1187{ 1131{
1188 RGB_PIXEL_COLOR corner_pixels[4]; 1132 RGB_PIXEL_COLOR corner_pixels[4];
@@ -1191,19 +1135,19 @@ four_corners_best (XImagePtr_or_DC ximg, int *corners,
1191 1135
1192 if (corners && corners[BOT_CORNER] >= 0) 1136 if (corners && corners[BOT_CORNER] >= 0)
1193 { 1137 {
1194 /* Get the colors at the corner_pixels of ximg. */ 1138 /* Get the colors at the corner_pixels of pimg. */
1195 corner_pixels[0] = GET_PIXEL (ximg, corners[LEFT_CORNER], corners[TOP_CORNER]); 1139 corner_pixels[0] = GET_PIXEL (pimg, corners[LEFT_CORNER], corners[TOP_CORNER]);
1196 corner_pixels[1] = GET_PIXEL (ximg, corners[RIGHT_CORNER] - 1, corners[TOP_CORNER]); 1140 corner_pixels[1] = GET_PIXEL (pimg, corners[RIGHT_CORNER] - 1, corners[TOP_CORNER]);
1197 corner_pixels[2] = GET_PIXEL (ximg, corners[RIGHT_CORNER] - 1, corners[BOT_CORNER] - 1); 1141 corner_pixels[2] = GET_PIXEL (pimg, corners[RIGHT_CORNER] - 1, corners[BOT_CORNER] - 1);
1198 corner_pixels[3] = GET_PIXEL (ximg, corners[LEFT_CORNER], corners[BOT_CORNER] - 1); 1142 corner_pixels[3] = GET_PIXEL (pimg, corners[LEFT_CORNER], corners[BOT_CORNER] - 1);
1199 } 1143 }
1200 else 1144 else
1201 { 1145 {
1202 /* Get the colors at the corner_pixels of ximg. */ 1146 /* Get the colors at the corner_pixels of pimg. */
1203 corner_pixels[0] = GET_PIXEL (ximg, 0, 0); 1147 corner_pixels[0] = GET_PIXEL (pimg, 0, 0);
1204 corner_pixels[1] = GET_PIXEL (ximg, width - 1, 0); 1148 corner_pixels[1] = GET_PIXEL (pimg, width - 1, 0);
1205 corner_pixels[2] = GET_PIXEL (ximg, width - 1, height - 1); 1149 corner_pixels[2] = GET_PIXEL (pimg, width - 1, height - 1);
1206 corner_pixels[3] = GET_PIXEL (ximg, 0, height - 1); 1150 corner_pixels[3] = GET_PIXEL (pimg, 0, height - 1);
1207 } 1151 }
1208 /* Choose the most frequently found color as background. */ 1152 /* Choose the most frequently found color as background. */
1209 for (i = best_count = 0; i < 4; ++i) 1153 for (i = best_count = 0; i < 4; ++i)
@@ -1221,49 +1165,29 @@ four_corners_best (XImagePtr_or_DC ximg, int *corners,
1221 return best; 1165 return best;
1222} 1166}
1223 1167
1224/* Portability macros */
1225
1226#ifdef HAVE_NTGUI
1227
1228#define Free_Pixmap(display, pixmap) \
1229 DeleteObject (pixmap)
1230
1231#elif defined (HAVE_NS)
1232
1233#define Free_Pixmap(display, pixmap) \
1234 ns_release_object (pixmap)
1235
1236#else
1237
1238#define Free_Pixmap(display, pixmap) \
1239 XFreePixmap (display, pixmap)
1240
1241#endif /* !HAVE_NTGUI && !HAVE_NS */
1242
1243
1244/* Return the `background' field of IMG. If IMG doesn't have one yet, 1168/* Return the `background' field of IMG. If IMG doesn't have one yet,
1245 it is guessed heuristically. If non-zero, XIMG is an existing 1169 it is guessed heuristically. If non-zero, XIMG is an existing
1246 XImage object (or device context with the image selected on W32) to 1170 Emacs_Pix_Context object (device context with the image selected on
1247 use for the heuristic. */ 1171 W32) to use for the heuristic. */
1248 1172
1249RGB_PIXEL_COLOR 1173RGB_PIXEL_COLOR
1250image_background (struct image *img, struct frame *f, XImagePtr_or_DC ximg) 1174image_background (struct image *img, struct frame *f, Emacs_Pix_Context pimg)
1251{ 1175{
1252 if (! img->background_valid) 1176 if (! img->background_valid)
1253 /* IMG doesn't have a background yet, try to guess a reasonable value. */ 1177 /* IMG doesn't have a background yet, try to guess a reasonable value. */
1254 { 1178 {
1255 bool free_ximg = !ximg; 1179 bool free_pimg = !pimg;
1256#ifdef HAVE_NTGUI 1180#ifdef HAVE_NTGUI
1257 HGDIOBJ prev; 1181 HGDIOBJ prev;
1258#endif /* HAVE_NTGUI */ 1182#endif /* HAVE_NTGUI */
1259 1183
1260 if (free_ximg) 1184 if (free_pimg)
1261 ximg = image_get_x_image_or_dc (f, img, 0, &prev); 1185 pimg = image_get_x_image_or_dc (f, img, 0, &prev);
1262 1186
1263 img->background = four_corners_best (ximg, img->corners, img->width, img->height); 1187 img->background = four_corners_best (pimg, img->corners, img->width, img->height);
1264 1188
1265 if (free_ximg) 1189 if (free_pimg)
1266 image_unget_x_image_or_dc (img, 0, ximg, prev); 1190 image_unget_x_image_or_dc (img, 0, pimg, prev);
1267 1191
1268 img->background_valid = 1; 1192 img->background_valid = 1;
1269 } 1193 }
@@ -1273,10 +1197,12 @@ image_background (struct image *img, struct frame *f, XImagePtr_or_DC ximg)
1273 1197
1274/* Return the `background_transparent' field of IMG. If IMG doesn't 1198/* Return the `background_transparent' field of IMG. If IMG doesn't
1275 have one yet, it is guessed heuristically. If non-zero, MASK is an 1199 have one yet, it is guessed heuristically. If non-zero, MASK is an
1276 existing XImage object to use for the heuristic. */ 1200 existing Emacs_Pix_Context (XImage* on X) object to use for the
1201 heuristic. */
1277 1202
1278int 1203int
1279image_background_transparent (struct image *img, struct frame *f, XImagePtr_or_DC mask) 1204image_background_transparent (struct image *img, struct frame *f,
1205 Emacs_Pix_Context mask)
1280{ 1206{
1281 if (! img->background_transparent_valid) 1207 if (! img->background_transparent_valid)
1282 /* IMG doesn't have a background yet, try to guess a reasonable value. */ 1208 /* IMG doesn't have a background yet, try to guess a reasonable value. */
@@ -1328,7 +1254,7 @@ image_clear_image_1 (struct frame *f, struct image *img, int flags)
1328 { 1254 {
1329 if (img->pixmap) 1255 if (img->pixmap)
1330 { 1256 {
1331 Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap); 1257 FRAME_TERMINAL (f)->free_pixmap (f, img->pixmap);
1332 img->pixmap = NO_PIXMAP; 1258 img->pixmap = NO_PIXMAP;
1333 /* NOTE (HAVE_NS): background color is NOT an indexed color! */ 1259 /* NOTE (HAVE_NS): background color is NOT an indexed color! */
1334 img->background_valid = 0; 1260 img->background_valid = 0;
@@ -1347,7 +1273,7 @@ image_clear_image_1 (struct frame *f, struct image *img, int flags)
1347 { 1273 {
1348 if (img->mask) 1274 if (img->mask)
1349 { 1275 {
1350 Free_Pixmap (FRAME_X_DISPLAY (f), img->mask); 1276 FRAME_TERMINAL (f)->free_pixmap (f, img->mask);
1351 img->mask = NO_PIXMAP; 1277 img->mask = NO_PIXMAP;
1352 img->background_transparent_valid = 0; 1278 img->background_transparent_valid = 0;
1353 } 1279 }
@@ -1399,7 +1325,7 @@ static unsigned long
1399image_alloc_image_color (struct frame *f, struct image *img, 1325image_alloc_image_color (struct frame *f, struct image *img,
1400 Lisp_Object color_name, unsigned long dflt) 1326 Lisp_Object color_name, unsigned long dflt)
1401{ 1327{
1402 XColor color; 1328 Emacs_Color color;
1403 unsigned long result; 1329 unsigned long result;
1404 1330
1405 eassert (STRINGP (color_name)); 1331 eassert (STRINGP (color_name));
@@ -2079,7 +2005,7 @@ mark_image_cache (struct image_cache *c)
2079 WIDTH and HEIGHT must both be positive. 2005 WIDTH and HEIGHT must both be positive.
2080 If XIMG is null, assume it is a bitmap. */ 2006 If XIMG is null, assume it is a bitmap. */
2081static bool 2007static bool
2082image_check_image_size (XImagePtr ximg, int width, int height) 2008image_check_image_size (Emacs_Pix_Container ximg, int width, int height)
2083{ 2009{
2084#ifdef HAVE_X_WINDOWS 2010#ifdef HAVE_X_WINDOWS
2085 /* Respect Xlib's limits: it cannot deal with images that have more 2011 /* Respect Xlib's limits: it cannot deal with images that have more
@@ -2113,18 +2039,20 @@ image_check_image_size (XImagePtr ximg, int width, int height)
2113#endif 2039#endif
2114} 2040}
2115 2041
2116/* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on 2042/* Create an Emacs_Pix_Container and a pixmap of size WIDTH x
2117 frame F. Set *XIMG and *PIXMAP to the XImage and Pixmap created. 2043 HEIGHT for use on frame F. Set *PIMG and *PIXMAP to the
2118 Set (*XIMG)->data to a raster of WIDTH x HEIGHT pixels allocated 2044 Emacs_Pix_Container and Emacs_Pixmap created. Set (*PIMG)->data
2119 via xmalloc. Print error messages via image_error if an error 2045 to a raster of WIDTH x HEIGHT pixels allocated via xmalloc. Print
2120 occurs. Value is true if successful. 2046 error messages via image_error if an error occurs. Value is true
2047 if successful.
2121 2048
2122 On W32, a DEPTH of zero signifies a 24 bit image, otherwise DEPTH 2049 On W32, a DEPTH of zero signifies a 24 bit image, otherwise DEPTH
2123 should indicate the bit depth of the image. */ 2050 should indicate the bit depth of the image. */
2124 2051
2125static bool 2052static bool
2126image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int depth, 2053image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int depth,
2127 XImagePtr *ximg, Pixmap *pixmap, Picture *picture) 2054 Emacs_Pix_Container *pimg,
2055 Emacs_Pixmap *pixmap, Picture *picture)
2128{ 2056{
2129#ifdef HAVE_X_WINDOWS 2057#ifdef HAVE_X_WINDOWS
2130 Display *display = FRAME_X_DISPLAY (f); 2058 Display *display = FRAME_X_DISPLAY (f);
@@ -2135,33 +2063,33 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
2135 2063
2136 if (depth <= 0) 2064 if (depth <= 0)
2137 depth = DefaultDepthOfScreen (screen); 2065 depth = DefaultDepthOfScreen (screen);
2138 *ximg = XCreateImage (display, DefaultVisualOfScreen (screen), 2066 *pimg = XCreateImage (display, DefaultVisualOfScreen (screen),
2139 depth, ZPixmap, 0, NULL, width, height, 2067 depth, ZPixmap, 0, NULL, width, height,
2140 depth > 16 ? 32 : depth > 8 ? 16 : 8, 0); 2068 depth > 16 ? 32 : depth > 8 ? 16 : 8, 0);
2141 if (*ximg == NULL) 2069 if (*pimg == NULL)
2142 { 2070 {
2143 image_error ("Unable to allocate X image"); 2071 image_error ("Unable to allocate X image");
2144 return 0; 2072 return 0;
2145 } 2073 }
2146 2074
2147 if (! image_check_image_size (*ximg, width, height)) 2075 if (! image_check_image_size (*pimg, width, height))
2148 { 2076 {
2149 image_destroy_x_image (*ximg); 2077 image_destroy_x_image (*pimg);
2150 *ximg = NULL; 2078 *pimg = NULL;
2151 image_error ("Image too large (%dx%d)", 2079 image_error ("Image too large (%dx%d)",
2152 make_fixnum (width), make_fixnum (height)); 2080 make_fixnum (width), make_fixnum (height));
2153 return 0; 2081 return 0;
2154 } 2082 }
2155 2083
2156 /* Allocate image raster. */ 2084 /* Allocate image raster. */
2157 (*ximg)->data = xmalloc ((*ximg)->bytes_per_line * height); 2085 (*pimg)->data = xmalloc ((*pimg)->bytes_per_line * height);
2158 2086
2159 /* Allocate a pixmap of the same size. */ 2087 /* Allocate a pixmap of the same size. */
2160 *pixmap = XCreatePixmap (display, drawable, width, height, depth); 2088 *pixmap = XCreatePixmap (display, drawable, width, height, depth);
2161 if (*pixmap == NO_PIXMAP) 2089 if (*pixmap == NO_PIXMAP)
2162 { 2090 {
2163 image_destroy_x_image (*ximg); 2091 image_destroy_x_image (*pimg);
2164 *ximg = NULL; 2092 *pimg = NULL;
2165 image_error ("Unable to create X pixmap"); 2093 image_error ("Unable to create X pixmap");
2166 return 0; 2094 return 0;
2167 } 2095 }
@@ -2228,10 +2156,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
2228 if (depth < 16) 2156 if (depth < 16)
2229 palette_colors = 1 << (depth - 1); 2157 palette_colors = 1 << (depth - 1);
2230 2158
2231 *ximg = xmalloc (sizeof (XImage) + palette_colors * sizeof (RGBQUAD)); 2159 *pimg = xmalloc (sizeof (XImage) + palette_colors * sizeof (RGBQUAD));
2232 2160
2233 header = &(*ximg)->info.bmiHeader; 2161 header = &(*pimg)->info.bmiHeader;
2234 memset (&(*ximg)->info, 0, sizeof (BITMAPINFO)); 2162 memset (&(*pimg)->info, 0, sizeof (BITMAPINFO));
2235 header->biSize = sizeof (*header); 2163 header->biSize = sizeof (*header);
2236 header->biWidth = width; 2164 header->biWidth = width;
2237 header->biHeight = -height; /* negative indicates a top-down bitmap. */ 2165 header->biHeight = -height; /* negative indicates a top-down bitmap. */
@@ -2243,10 +2171,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
2243 /* TODO: fill in palette. */ 2171 /* TODO: fill in palette. */
2244 if (depth == 1) 2172 if (depth == 1)
2245 { 2173 {
2246 (*ximg)->info.bmiColors[0].rgbBlue = 0; 2174 (*pimg)->info.bmiColors[0].rgbBlue = 0;
2247 (*ximg)->info.bmiColors[0].rgbGreen = 0; 2175 (*pimg)->info.bmiColors[0].rgbGreen = 0;
2248 (*ximg)->info.bmiColors[0].rgbRed = 0; 2176 (*pimg)->info.bmiColors[0].rgbRed = 0;
2249 (*ximg)->info.bmiColors[0].rgbReserved = 0; 2177 (*pimg)->info.bmiColors[0].rgbReserved = 0;
2250 /* bmiColors is a variable-length array declared by w32api 2178 /* bmiColors is a variable-length array declared by w32api
2251 headers as bmiColors[1], which triggers a warning under 2179 headers as bmiColors[1], which triggers a warning under
2252 -Warray-bounds; shut that up. */ 2180 -Warray-bounds; shut that up. */
@@ -2254,10 +2182,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
2254# pragma GCC push_options 2182# pragma GCC push_options
2255# pragma GCC diagnostic ignored "-Warray-bounds" 2183# pragma GCC diagnostic ignored "-Warray-bounds"
2256# endif 2184# endif
2257 (*ximg)->info.bmiColors[1].rgbBlue = 255; 2185 (*pimg)->info.bmiColors[1].rgbBlue = 255;
2258 (*ximg)->info.bmiColors[1].rgbGreen = 255; 2186 (*pimg)->info.bmiColors[1].rgbGreen = 255;
2259 (*ximg)->info.bmiColors[1].rgbRed = 255; 2187 (*pimg)->info.bmiColors[1].rgbRed = 255;
2260 (*ximg)->info.bmiColors[1].rgbReserved = 0; 2188 (*pimg)->info.bmiColors[1].rgbReserved = 0;
2261# if GNUC_PREREQ (4, 4, 0) 2189# if GNUC_PREREQ (4, 4, 0)
2262# pragma GCC pop_options 2190# pragma GCC pop_options
2263# endif 2191# endif
@@ -2267,10 +2195,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
2267 2195
2268 /* Create a DIBSection and raster array for the bitmap, 2196 /* Create a DIBSection and raster array for the bitmap,
2269 and store its handle in *pixmap. */ 2197 and store its handle in *pixmap. */
2270 *pixmap = CreateDIBSection (hdc, &((*ximg)->info), 2198 *pixmap = CreateDIBSection (hdc, &((*pimg)->info),
2271 (depth < 16) ? DIB_PAL_COLORS : DIB_RGB_COLORS, 2199 (depth < 16) ? DIB_PAL_COLORS : DIB_RGB_COLORS,
2272 /* casting avoids a GCC warning */ 2200 /* casting avoids a GCC warning */
2273 (void **)&((*ximg)->data), NULL, 0); 2201 (void **)&((*pimg)->data), NULL, 0);
2274 2202
2275 /* Realize display palette and garbage all frames. */ 2203 /* Realize display palette and garbage all frames. */
2276 release_frame_dc (f, hdc); 2204 release_frame_dc (f, hdc);
@@ -2282,8 +2210,8 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
2282 /* All system errors are < 10000, so the following is safe. */ 2210 /* All system errors are < 10000, so the following is safe. */
2283 XSETINT (errcode, err); 2211 XSETINT (errcode, err);
2284 image_error ("Unable to create bitmap, error code %d", errcode); 2212 image_error ("Unable to create bitmap, error code %d", errcode);
2285 image_destroy_x_image (*ximg); 2213 image_destroy_x_image (*pimg);
2286 *ximg = NULL; 2214 *pimg = NULL;
2287 return 0; 2215 return 0;
2288 } 2216 }
2289 2217
@@ -2295,69 +2223,70 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
2295 *pixmap = ns_image_for_XPM (width, height, depth); 2223 *pixmap = ns_image_for_XPM (width, height, depth);
2296 if (*pixmap == 0) 2224 if (*pixmap == 0)
2297 { 2225 {
2298 *ximg = NULL; 2226 *pimg = NULL;
2299 image_error ("Unable to allocate NSImage for XPM pixmap"); 2227 image_error ("Unable to allocate NSImage for XPM pixmap");
2300 return 0; 2228 return 0;
2301 } 2229 }
2302 *ximg = *pixmap; 2230 *pimg = *pixmap;
2303 return 1; 2231 return 1;
2304#endif 2232#endif
2305} 2233}
2306 2234
2307 2235
2308/* Destroy XImage XIMG. Free XIMG->data. */ 2236/* Destroy Emacs_Pix_Container PIMG. Free data associated with PIMG. */
2309 2237
2310static void 2238static void
2311image_destroy_x_image (XImagePtr ximg) 2239image_destroy_x_image (Emacs_Pix_Container pimg)
2312{ 2240{
2313 eassert (input_blocked_p ()); 2241 eassert (input_blocked_p ());
2314 if (ximg) 2242 if (pimg)
2315 { 2243 {
2316#ifdef HAVE_X_WINDOWS 2244#ifdef HAVE_X_WINDOWS
2317 xfree (ximg->data); 2245 xfree (pimg->data);
2318 ximg->data = NULL; 2246 pimg->data = NULL;
2319 XDestroyImage (ximg); 2247 XDestroyImage (pimg);
2320#endif /* HAVE_X_WINDOWS */ 2248#endif /* HAVE_X_WINDOWS */
2321#ifdef HAVE_NTGUI 2249#ifdef HAVE_NTGUI
2322 /* Data will be freed by DestroyObject. */ 2250 /* Data will be freed by DestroyObject. */
2323 ximg->data = NULL; 2251 pimg->data = NULL;
2324 xfree (ximg); 2252 xfree (pimg);
2325#endif /* HAVE_NTGUI */ 2253#endif /* HAVE_NTGUI */
2326#ifdef HAVE_NS 2254#ifdef HAVE_NS
2327 ns_release_object (ximg); 2255 ns_release_object (pimg);
2328#endif /* HAVE_NS */ 2256#endif /* HAVE_NS */
2329 } 2257 }
2330} 2258}
2331 2259
2332 2260
2333/* Put XImage XIMG into pixmap PIXMAP on frame F. WIDTH and HEIGHT 2261/* Put Emacs_Pix_Container PIMG into pixmap PIXMAP on frame F.
2334 are width and height of both the image and pixmap. */ 2262 WIDTH and HEIGHT are width and height of both the image and
2263 pixmap. */
2335 2264
2336static void 2265static void
2337gui_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap, 2266gui_put_x_image (struct frame *f, Emacs_Pix_Container pimg,
2338 int width, int height) 2267 Emacs_Pixmap pixmap, int width, int height)
2339{ 2268{
2340#ifdef HAVE_X_WINDOWS 2269#ifdef HAVE_X_WINDOWS
2341 GC gc; 2270 GC gc;
2342 2271
2343 eassert (input_blocked_p ()); 2272 eassert (input_blocked_p ());
2344 gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL); 2273 gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL);
2345 XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0, 2274 XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, pimg, 0, 0, 0, 0,
2346 ximg->width, ximg->height); 2275 pimg->width, pimg->height);
2347 XFreeGC (FRAME_X_DISPLAY (f), gc); 2276 XFreeGC (FRAME_X_DISPLAY (f), gc);
2348#endif /* HAVE_X_WINDOWS */ 2277#endif /* HAVE_X_WINDOWS */
2349 2278
2350#ifdef HAVE_NTGUI 2279#ifdef HAVE_NTGUI
2351#if 0 /* I don't think this is necessary looking at where it is used. */ 2280#if 0 /* I don't think this is necessary looking at where it is used. */
2352 HDC hdc = get_frame_dc (f); 2281 HDC hdc = get_frame_dc (f);
2353 SetDIBits (hdc, pixmap, 0, height, ximg->data, &(ximg->info), DIB_RGB_COLORS); 2282 SetDIBits (hdc, pixmap, 0, height, pimg->data, &(pimg->info), DIB_RGB_COLORS);
2354 release_frame_dc (f, hdc); 2283 release_frame_dc (f, hdc);
2355#endif 2284#endif
2356#endif /* HAVE_NTGUI */ 2285#endif /* HAVE_NTGUI */
2357 2286
2358#ifdef HAVE_NS 2287#ifdef HAVE_NS
2359 eassert (ximg == pixmap); 2288 eassert (pimg == pixmap);
2360 ns_retain_object (ximg); 2289 ns_retain_object (pimg);
2361#endif 2290#endif
2362} 2291}
2363 2292
@@ -2367,7 +2296,7 @@ gui_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap,
2367static bool 2296static bool
2368image_create_x_image_and_pixmap (struct frame *f, struct image *img, 2297image_create_x_image_and_pixmap (struct frame *f, struct image *img,
2369 int width, int height, int depth, 2298 int width, int height, int depth,
2370 XImagePtr *ximg, bool mask_p) 2299 Emacs_Pix_Container *ximg, bool mask_p)
2371{ 2300{
2372 eassert ((!mask_p ? img->pixmap : img->mask) == NO_PIXMAP); 2301 eassert ((!mask_p ? img->pixmap : img->mask) == NO_PIXMAP);
2373 2302
@@ -2380,14 +2309,14 @@ image_create_x_image_and_pixmap (struct frame *f, struct image *img,
2380 picture); 2309 picture);
2381} 2310}
2382 2311
2383/* Put X image XIMG into image IMG on frame F, as a mask if and only 2312/* Put pixel image PIMG into image IMG on frame F, as a mask if and only
2384 if MASK_P. On X, this simply records XIMG on a member of IMG, so 2313 if MASK_P. On X, this simply records PIMG on a member of IMG, so
2385 it can be put into the pixmap afterwards via image_sync_to_pixmaps. 2314 it can be put into the pixmap afterwards via image_sync_to_pixmaps.
2386 On the other platforms, it puts XIMG into the pixmap, then frees 2315 On the other platforms, it puts PIMG into the pixmap, then frees
2387 the X image and its buffer. */ 2316 the pixel image and its buffer. */
2388 2317
2389static void 2318static void
2390image_put_x_image (struct frame *f, struct image *img, XImagePtr ximg, 2319image_put_x_image (struct frame *f, struct image *img, Emacs_Pix_Container ximg,
2391 bool mask_p) 2320 bool mask_p)
2392{ 2321{
2393#ifdef HAVE_X_WINDOWS 2322#ifdef HAVE_X_WINDOWS
@@ -2435,12 +2364,12 @@ image_sync_to_pixmaps (struct frame *f, struct image *img)
2435 currently selected GDI object into *PREV for future restoration by 2364 currently selected GDI object into *PREV for future restoration by
2436 image_unget_x_image_or_dc. */ 2365 image_unget_x_image_or_dc. */
2437 2366
2438static XImagePtr_or_DC 2367static HDC
2439image_get_x_image_or_dc (struct frame *f, struct image *img, bool mask_p, 2368image_get_x_image_or_dc (struct frame *f, struct image *img, bool mask_p,
2440 HGDIOBJ *prev) 2369 HGDIOBJ *prev)
2441{ 2370{
2442 HDC frame_dc = get_frame_dc (f); 2371 HDC frame_dc = get_frame_dc (f);
2443 XImagePtr_or_DC ximg = CreateCompatibleDC (frame_dc); 2372 HDC ximg = CreateCompatibleDC (frame_dc);
2444 2373
2445 release_frame_dc (f, frame_dc); 2374 release_frame_dc (f, frame_dc);
2446 *prev = SelectObject (ximg, !mask_p ? img->pixmap : img->mask); 2375 *prev = SelectObject (ximg, !mask_p ? img->pixmap : img->mask);
@@ -2450,7 +2379,7 @@ image_get_x_image_or_dc (struct frame *f, struct image *img, bool mask_p,
2450 2379
2451static void 2380static void
2452image_unget_x_image_or_dc (struct image *img, bool mask_p, 2381image_unget_x_image_or_dc (struct image *img, bool mask_p,
2453 XImagePtr_or_DC ximg, HGDIOBJ prev) 2382 HDC ximg, HGDIOBJ prev)
2454{ 2383{
2455 SelectObject (ximg, prev); 2384 SelectObject (ximg, prev);
2456 DeleteDC (ximg); 2385 DeleteDC (ximg);
@@ -2459,11 +2388,11 @@ image_unget_x_image_or_dc (struct image *img, bool mask_p,
2459/* Get the X image for IMG on frame F. The resulting X image data 2388/* Get the X image for IMG on frame F. The resulting X image data
2460 should be treated as read-only at least on X. */ 2389 should be treated as read-only at least on X. */
2461 2390
2462static XImagePtr 2391static Emacs_Pix_Container
2463image_get_x_image (struct frame *f, struct image *img, bool mask_p) 2392image_get_x_image (struct frame *f, struct image *img, bool mask_p)
2464{ 2393{
2465#ifdef HAVE_X_WINDOWS 2394#ifdef HAVE_X_WINDOWS
2466 XImagePtr ximg_in_img = !mask_p ? img->ximg : img->mask_img; 2395 XImage *ximg_in_img = !mask_p ? img->ximg : img->mask_img;
2467 2396
2468 if (ximg_in_img) 2397 if (ximg_in_img)
2469 return ximg_in_img; 2398 return ximg_in_img;
@@ -2471,7 +2400,7 @@ image_get_x_image (struct frame *f, struct image *img, bool mask_p)
2471 return XGetImage (FRAME_X_DISPLAY (f), !mask_p ? img->pixmap : img->mask, 2400 return XGetImage (FRAME_X_DISPLAY (f), !mask_p ? img->pixmap : img->mask,
2472 0, 0, img->width, img->height, ~0, ZPixmap); 2401 0, 0, img->width, img->height, ~0, ZPixmap);
2473#elif defined (HAVE_NS) 2402#elif defined (HAVE_NS)
2474 XImagePtr pixmap = !mask_p ? img->pixmap : img->mask; 2403 Emacs_Pix_Container pixmap = !mask_p ? img->pixmap : img->mask;
2475 2404
2476 ns_retain_object (pixmap); 2405 ns_retain_object (pixmap);
2477 return pixmap; 2406 return pixmap;
@@ -2479,10 +2408,10 @@ image_get_x_image (struct frame *f, struct image *img, bool mask_p)
2479} 2408}
2480 2409
2481static void 2410static void
2482image_unget_x_image (struct image *img, bool mask_p, XImagePtr ximg) 2411image_unget_x_image (struct image *img, bool mask_p, Emacs_Pix_Container ximg)
2483{ 2412{
2484#ifdef HAVE_X_WINDOWS 2413#ifdef HAVE_X_WINDOWS
2485 XImagePtr ximg_in_img = !mask_p ? img->ximg : img->mask_img; 2414 XImage *ximg_in_img = !mask_p ? img->ximg : img->mask_img;
2486 2415
2487 if (ximg_in_img) 2416 if (ximg_in_img)
2488 eassert (ximg == ximg_in_img); 2417 eassert (ximg == ximg_in_img);
@@ -2595,8 +2524,6 @@ slurp_file (int fd, ptrdiff_t *size)
2595 XBM images 2524 XBM images
2596 ***********************************************************************/ 2525 ***********************************************************************/
2597 2526
2598static bool xbm_load (struct frame *f, struct image *img);
2599static bool xbm_image_p (Lisp_Object object);
2600static bool xbm_file_p (Lisp_Object); 2527static bool xbm_file_p (Lisp_Object);
2601 2528
2602 2529
@@ -2640,18 +2567,6 @@ static const struct image_keyword xbm_format[XBM_LAST] =
2640 {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} 2567 {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
2641}; 2568};
2642 2569
2643/* Structure describing the image type XBM. */
2644
2645static struct image_type xbm_type =
2646{
2647 SYMBOL_INDEX (Qxbm),
2648 xbm_image_p,
2649 xbm_load,
2650 image_clear_image,
2651 NULL,
2652 NULL
2653};
2654
2655/* Tokens returned from xbm_scan. */ 2570/* Tokens returned from xbm_scan. */
2656 2571
2657enum xbm_token 2572enum xbm_token
@@ -3377,13 +3292,6 @@ xbm_load (struct frame *f, struct image *img)
3377 XPM images 3292 XPM images
3378 ***********************************************************************/ 3293 ***********************************************************************/
3379 3294
3380#if defined (HAVE_XPM) || defined (HAVE_NS)
3381
3382static bool xpm_image_p (Lisp_Object object);
3383static bool xpm_load (struct frame *f, struct image *img);
3384
3385#endif /* HAVE_XPM || HAVE_NS */
3386
3387#ifdef HAVE_XPM 3295#ifdef HAVE_XPM
3388#ifdef HAVE_NTGUI 3296#ifdef HAVE_NTGUI
3389/* Indicate to xpm.h that we don't have Xlib. */ 3297/* Indicate to xpm.h that we don't have Xlib. */
@@ -3445,24 +3353,6 @@ static const struct image_keyword xpm_format[XPM_LAST] =
3445 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 3353 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
3446}; 3354};
3447 3355
3448#if defined HAVE_NTGUI && defined WINDOWSNT
3449static bool init_xpm_functions (void);
3450#else
3451#define init_xpm_functions NULL
3452#endif
3453
3454/* Structure describing the image type XPM. */
3455
3456static struct image_type xpm_type =
3457{
3458 SYMBOL_INDEX (Qxpm),
3459 xpm_image_p,
3460 xpm_load,
3461 image_clear_image,
3462 init_xpm_functions,
3463 NULL
3464};
3465
3466#ifdef HAVE_X_WINDOWS 3356#ifdef HAVE_X_WINDOWS
3467 3357
3468/* Define ALLOC_XPM_COLORS if we can use Emacs' own color allocation 3358/* Define ALLOC_XPM_COLORS if we can use Emacs' own color allocation
@@ -4318,7 +4208,7 @@ xpm_load_image (struct frame *f,
4318#ifndef HAVE_NS 4208#ifndef HAVE_NS
4319 bool have_mask = false; 4209 bool have_mask = false;
4320#endif 4210#endif
4321 XImagePtr ximg = NULL, mask_img = NULL; 4211 Emacs_Pix_Container ximg = NULL, mask_img = NULL;
4322 4212
4323#define match() \ 4213#define match() \
4324 LA1 = xpm_scan (&s, end, &beg, &len) 4214 LA1 = xpm_scan (&s, end, &beg, &len)
@@ -4403,7 +4293,7 @@ xpm_load_image (struct frame *f,
4403 char *color, *max_color; 4293 char *color, *max_color;
4404 int key, next_key, max_key = 0; 4294 int key, next_key, max_key = 0;
4405 Lisp_Object symbol_color = Qnil, color_val; 4295 Lisp_Object symbol_color = Qnil, color_val;
4406 XColor cdef; 4296 Emacs_Color cdef;
4407 4297
4408 expect (XPM_TK_STRING); 4298 expect (XPM_TK_STRING);
4409 if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel) 4299 if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel)
@@ -4889,18 +4779,18 @@ static int laplace_matrix[9] = {
4889#define COLOR_INTENSITY(R, G, B) ((2 * (R) + 3 * (G) + (B)) / 6) 4779#define COLOR_INTENSITY(R, G, B) ((2 * (R) + 3 * (G) + (B)) / 6)
4890 4780
4891 4781
4892/* On frame F, return an array of XColor structures describing image 4782/* On frame F, return an array of Emacs_Color structures describing image
4893 IMG->pixmap. Each XColor structure has its pixel color set. RGB_P 4783 IMG->pixmap. Each Emacs_Color structure has its pixel color set. RGB_P
4894 means also fill the red/green/blue members of the XColor 4784 means also fill the red/green/blue members of the Emacs_Color
4895 structures. Value is a pointer to the array of XColors structures, 4785 structures. Value is a pointer to the array of Emacs_Color structures,
4896 allocated with xmalloc; it must be freed by the caller. */ 4786 allocated with xmalloc; it must be freed by the caller. */
4897 4787
4898static XColor * 4788static Emacs_Color *
4899image_to_xcolors (struct frame *f, struct image *img, bool rgb_p) 4789image_to_emacs_colors (struct frame *f, struct image *img, bool rgb_p)
4900{ 4790{
4901 int x, y; 4791 int x, y;
4902 XColor *colors, *p; 4792 Emacs_Color *colors, *p;
4903 XImagePtr_or_DC ximg; 4793 Emacs_Pix_Context ximg;
4904 ptrdiff_t nbytes; 4794 ptrdiff_t nbytes;
4905#ifdef HAVE_NTGUI 4795#ifdef HAVE_NTGUI
4906 HGDIOBJ prev; 4796 HGDIOBJ prev;
@@ -4915,13 +4805,13 @@ image_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
4915 /* Get the X image or create a memory device context for IMG. */ 4805 /* Get the X image or create a memory device context for IMG. */
4916 ximg = image_get_x_image_or_dc (f, img, 0, &prev); 4806 ximg = image_get_x_image_or_dc (f, img, 0, &prev);
4917 4807
4918 /* Fill the `pixel' members of the XColor array. I wished there 4808 /* Fill the `pixel' members of the Emacs_Color array. I wished there
4919 were an easy and portable way to circumvent XGetPixel. */ 4809 were an easy and portable way to circumvent XGetPixel. */
4920 p = colors; 4810 p = colors;
4921 for (y = 0; y < img->height; ++y) 4811 for (y = 0; y < img->height; ++y)
4922 { 4812 {
4923#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) 4813#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
4924 XColor *row = p; 4814 Emacs_Color *row = p;
4925 for (x = 0; x < img->width; ++x, ++p) 4815 for (x = 0; x < img->width; ++x, ++p)
4926 p->pixel = GET_PIXEL (ximg, x, y); 4816 p->pixel = GET_PIXEL (ximg, x, y);
4927 if (rgb_p) 4817 if (rgb_p)
@@ -4956,7 +4846,7 @@ image_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
4956 stored in ximg->data. */ 4846 stored in ximg->data. */
4957 4847
4958static void 4848static void
4959XPutPixel (XImagePtr ximg, int x, int y, COLORREF color) 4849XPutPixel (XImage *ximg, int x, int y, COLORREF color)
4960{ 4850{
4961 int width = ximg->info.bmiHeader.biWidth; 4851 int width = ximg->info.bmiHeader.biWidth;
4962 unsigned char * pixel; 4852 unsigned char * pixel;
@@ -4995,16 +4885,16 @@ XPutPixel (XImagePtr ximg, int x, int y, COLORREF color)
4995 4885
4996#endif /* HAVE_NTGUI */ 4886#endif /* HAVE_NTGUI */
4997 4887
4998/* Create IMG->pixmap from an array COLORS of XColor structures, whose 4888/* Create IMG->pixmap from an array COLORS of Emacs_Color structures, whose
4999 RGB members are set. F is the frame on which this all happens. 4889 RGB members are set. F is the frame on which this all happens.
5000 COLORS will be freed; an existing IMG->pixmap will be freed, too. */ 4890 COLORS will be freed; an existing IMG->pixmap will be freed, too. */
5001 4891
5002static void 4892static void
5003image_from_xcolors (struct frame *f, struct image *img, XColor *colors) 4893image_from_emacs_colors (struct frame *f, struct image *img, Emacs_Color *colors)
5004{ 4894{
5005 int x, y; 4895 int x, y;
5006 XImagePtr oimg = NULL; 4896 Emacs_Pix_Container oimg = NULL;
5007 XColor *p; 4897 Emacs_Color *p;
5008 4898
5009 init_color_table (); 4899 init_color_table ();
5010 4900
@@ -5042,8 +4932,8 @@ static void
5042image_detect_edges (struct frame *f, struct image *img, 4932image_detect_edges (struct frame *f, struct image *img,
5043 int *matrix, int color_adjust) 4933 int *matrix, int color_adjust)
5044{ 4934{
5045 XColor *colors = image_to_xcolors (f, img, 1); 4935 Emacs_Color *colors = image_to_emacs_colors (f, img, 1);
5046 XColor *new, *p; 4936 Emacs_Color *new, *p;
5047 int x, y, i, sum; 4937 int x, y, i, sum;
5048 ptrdiff_t nbytes; 4938 ptrdiff_t nbytes;
5049 4939
@@ -5086,7 +4976,7 @@ image_detect_edges (struct frame *f, struct image *img,
5086 for (xx = x - 1; xx < x + 2; ++xx, ++i) 4976 for (xx = x - 1; xx < x + 2; ++xx, ++i)
5087 if (matrix[i]) 4977 if (matrix[i])
5088 { 4978 {
5089 XColor *t = COLOR (colors, xx, yy); 4979 Emacs_Color *t = COLOR (colors, xx, yy);
5090 r += matrix[i] * t->red; 4980 r += matrix[i] * t->red;
5091 g += matrix[i] * t->green; 4981 g += matrix[i] * t->green;
5092 b += matrix[i] * t->blue; 4982 b += matrix[i] * t->blue;
@@ -5100,7 +4990,7 @@ image_detect_edges (struct frame *f, struct image *img,
5100 } 4990 }
5101 4991
5102 xfree (colors); 4992 xfree (colors);
5103 image_from_xcolors (f, img, new); 4993 image_from_emacs_colors (f, img, new);
5104 4994
5105#undef COLOR 4995#undef COLOR
5106} 4996}
@@ -5183,8 +5073,8 @@ image_disable_image (struct frame *f, struct image *img)
5183 /* Color (or grayscale). Convert to gray, and equalize. Just 5073 /* Color (or grayscale). Convert to gray, and equalize. Just
5184 drawing such images with a stipple can look very odd, so 5074 drawing such images with a stipple can look very odd, so
5185 we're using this method instead. */ 5075 we're using this method instead. */
5186 XColor *colors = image_to_xcolors (f, img, 1); 5076 Emacs_Color *colors = image_to_emacs_colors (f, img, 1);
5187 XColor *p, *end; 5077 Emacs_Color *p, *end;
5188 const int h = 15000; 5078 const int h = 15000;
5189 const int l = 30000; 5079 const int l = 30000;
5190 5080
@@ -5197,7 +5087,7 @@ image_disable_image (struct frame *f, struct image *img)
5197 p->red = p->green = p->blue = i2; 5087 p->red = p->green = p->blue = i2;
5198 } 5088 }
5199 5089
5200 image_from_xcolors (f, img, colors); 5090 image_from_emacs_colors (f, img, colors);
5201 } 5091 }
5202 5092
5203 /* Draw a cross over the disabled image, if we must or if we 5093 /* Draw a cross over the disabled image, if we must or if we
@@ -5275,13 +5165,13 @@ static void
5275image_build_heuristic_mask (struct frame *f, struct image *img, 5165image_build_heuristic_mask (struct frame *f, struct image *img,
5276 Lisp_Object how) 5166 Lisp_Object how)
5277{ 5167{
5278 XImagePtr_or_DC ximg; 5168 Emacs_Pix_Context ximg;
5279#ifdef HAVE_NTGUI 5169#ifdef HAVE_NTGUI
5280 HGDIOBJ prev; 5170 HGDIOBJ prev;
5281 char *mask_img; 5171 char *mask_img;
5282 int row_width; 5172 int row_width;
5283#elif !defined HAVE_NS 5173#elif !defined HAVE_NS
5284 XImagePtr mask_img; 5174 Emacs_Pix_Container mask_img;
5285#endif 5175#endif
5286 int x, y; 5176 int x, y;
5287 bool use_img_background; 5177 bool use_img_background;
@@ -5384,9 +5274,6 @@ image_build_heuristic_mask (struct frame *f, struct image *img,
5384 PBM (mono, gray, color) 5274 PBM (mono, gray, color)
5385 ***********************************************************************/ 5275 ***********************************************************************/
5386 5276
5387static bool pbm_image_p (Lisp_Object object);
5388static bool pbm_load (struct frame *f, struct image *img);
5389
5390/* Indices of image specification fields in gs_format, below. */ 5277/* Indices of image specification fields in gs_format, below. */
5391 5278
5392enum pbm_keyword_index 5279enum pbm_keyword_index
@@ -5423,19 +5310,6 @@ static const struct image_keyword pbm_format[PBM_LAST] =
5423 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 5310 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
5424}; 5311};
5425 5312
5426/* Structure describing the image type `pbm'. */
5427
5428static struct image_type pbm_type =
5429{
5430 SYMBOL_INDEX (Qpbm),
5431 pbm_image_p,
5432 pbm_load,
5433 image_clear_image,
5434 NULL,
5435 NULL
5436};
5437
5438
5439/* Return true if OBJECT is a valid PBM image specification. */ 5313/* Return true if OBJECT is a valid PBM image specification. */
5440 5314
5441static bool 5315static bool
@@ -5533,7 +5407,7 @@ pbm_load (struct frame *f, struct image *img)
5533 char *contents = NULL; 5407 char *contents = NULL;
5534 char *end, *p; 5408 char *end, *p;
5535#ifndef USE_CAIRO 5409#ifndef USE_CAIRO
5536 XImagePtr ximg; 5410 Emacs_Pix_Container ximg;
5537#endif 5411#endif
5538 5412
5539 specified_file = image_spec_value (img->spec, QCfile, NULL); 5413 specified_file = image_spec_value (img->spec, QCfile, NULL);
@@ -5655,7 +5529,7 @@ pbm_load (struct frame *f, struct image *img)
5655 unsigned long fg = FRAME_FOREGROUND_PIXEL (f); 5529 unsigned long fg = FRAME_FOREGROUND_PIXEL (f);
5656 unsigned long bg = FRAME_BACKGROUND_PIXEL (f); 5530 unsigned long bg = FRAME_BACKGROUND_PIXEL (f);
5657#ifdef USE_CAIRO 5531#ifdef USE_CAIRO
5658 XColor xfg, xbg; 5532 Emacs_Color xfg, xbg;
5659 int fga32, bga32; 5533 int fga32, bga32;
5660#endif 5534#endif
5661 /* Parse the image specification. */ 5535 /* Parse the image specification. */
@@ -5675,7 +5549,7 @@ pbm_load (struct frame *f, struct image *img)
5675 xfg.pixel = fg; 5549 xfg.pixel = fg;
5676 x_query_colors (f, &xfg, 1); 5550 x_query_colors (f, &xfg, 1);
5677 } 5551 }
5678 fga32 = xcolor_to_argb32 (xfg); 5552 fga32 = emacs_color_to_argb32 (&xfg);
5679 5553
5680 if (! fmt[PBM_BACKGROUND].count 5554 if (! fmt[PBM_BACKGROUND].count
5681 || ! STRINGP (fmt[PBM_BACKGROUND].value) 5555 || ! STRINGP (fmt[PBM_BACKGROUND].value)
@@ -5688,7 +5562,7 @@ pbm_load (struct frame *f, struct image *img)
5688 xbg.pixel = bg; 5562 xbg.pixel = bg;
5689 x_query_colors (f, &xbg, 1); 5563 x_query_colors (f, &xbg, 1);
5690 } 5564 }
5691 bga32 = xcolor_to_argb32 (xbg); 5565 bga32 = emacs_color_to_argb32 (&xbg);
5692#else 5566#else
5693 if (fmt[PBM_FOREGROUND].count 5567 if (fmt[PBM_FOREGROUND].count
5694 && STRINGP (fmt[PBM_FOREGROUND].value)) 5568 && STRINGP (fmt[PBM_FOREGROUND].value))
@@ -5833,7 +5707,7 @@ pbm_load (struct frame *f, struct image *img)
5833#else 5707#else
5834 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 5708 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
5835 /* Casting avoids a GCC warning. */ 5709 /* Casting avoids a GCC warning. */
5836 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); 5710 IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
5837 5711
5838 /* Put ximg into the image. */ 5712 /* Put ximg into the image. */
5839 image_put_x_image (f, img, ximg, 0); 5713 image_put_x_image (f, img, ximg, 0);
@@ -5854,11 +5728,6 @@ pbm_load (struct frame *f, struct image *img)
5854 5728
5855#if defined (HAVE_PNG) || defined (HAVE_NS) || defined (USE_CAIRO) 5729#if defined (HAVE_PNG) || defined (HAVE_NS) || defined (USE_CAIRO)
5856 5730
5857/* Function prototypes. */
5858
5859static bool png_image_p (Lisp_Object object);
5860static bool png_load (struct frame *f, struct image *img);
5861
5862/* Indices of image specification fields in png_format, below. */ 5731/* Indices of image specification fields in png_format, below. */
5863 5732
5864enum png_keyword_index 5733enum png_keyword_index
@@ -5893,24 +5762,6 @@ static const struct image_keyword png_format[PNG_LAST] =
5893 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 5762 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
5894}; 5763};
5895 5764
5896#if defined HAVE_NTGUI && defined WINDOWSNT
5897static bool init_png_functions (void);
5898#else
5899#define init_png_functions NULL
5900#endif
5901
5902/* Structure describing the image type `png'. */
5903
5904static struct image_type png_type =
5905{
5906 SYMBOL_INDEX (Qpng),
5907 png_image_p,
5908 png_load,
5909 image_clear_image,
5910 init_png_functions,
5911 NULL
5912};
5913
5914/* Return true if OBJECT is a valid PNG image specification. */ 5765/* Return true if OBJECT is a valid PNG image specification. */
5915 5766
5916static bool 5767static bool
@@ -5951,6 +5802,7 @@ DEF_DLL_FN (png_uint_32, png_get_valid, (png_structp, png_infop, png_uint_32));
5951DEF_DLL_FN (void, png_set_strip_16, (png_structp)); 5802DEF_DLL_FN (void, png_set_strip_16, (png_structp));
5952DEF_DLL_FN (void, png_set_expand, (png_structp)); 5803DEF_DLL_FN (void, png_set_expand, (png_structp));
5953DEF_DLL_FN (void, png_set_gray_to_rgb, (png_structp)); 5804DEF_DLL_FN (void, png_set_gray_to_rgb, (png_structp));
5805DEF_DLL_FN (int, png_set_interlace_handling, (png_structp));
5954DEF_DLL_FN (void, png_set_background, 5806DEF_DLL_FN (void, png_set_background,
5955 (png_structp, png_color_16p, int, int, double)); 5807 (png_structp, png_color_16p, int, int, double));
5956DEF_DLL_FN (png_uint_32, png_get_bKGD, 5808DEF_DLL_FN (png_uint_32, png_get_bKGD,
@@ -5989,6 +5841,7 @@ init_png_functions (void)
5989 LOAD_DLL_FN (library, png_set_strip_16); 5841 LOAD_DLL_FN (library, png_set_strip_16);
5990 LOAD_DLL_FN (library, png_set_expand); 5842 LOAD_DLL_FN (library, png_set_expand);
5991 LOAD_DLL_FN (library, png_set_gray_to_rgb); 5843 LOAD_DLL_FN (library, png_set_gray_to_rgb);
5844 LOAD_DLL_FN (library, png_set_interlace_handling);
5992 LOAD_DLL_FN (library, png_set_background); 5845 LOAD_DLL_FN (library, png_set_background);
5993 LOAD_DLL_FN (library, png_get_bKGD); 5846 LOAD_DLL_FN (library, png_get_bKGD);
5994 LOAD_DLL_FN (library, png_read_update_info); 5847 LOAD_DLL_FN (library, png_read_update_info);
@@ -6024,6 +5877,7 @@ init_png_functions (void)
6024# undef png_set_background 5877# undef png_set_background
6025# undef png_set_expand 5878# undef png_set_expand
6026# undef png_set_gray_to_rgb 5879# undef png_set_gray_to_rgb
5880# undef png_set_interlace_handling
6027# undef png_set_longjmp_fn 5881# undef png_set_longjmp_fn
6028# undef png_set_read_fn 5882# undef png_set_read_fn
6029# undef png_set_sig_bytes 5883# undef png_set_sig_bytes
@@ -6048,6 +5902,7 @@ init_png_functions (void)
6048# define png_set_background fn_png_set_background 5902# define png_set_background fn_png_set_background
6049# define png_set_expand fn_png_set_expand 5903# define png_set_expand fn_png_set_expand
6050# define png_set_gray_to_rgb fn_png_set_gray_to_rgb 5904# define png_set_gray_to_rgb fn_png_set_gray_to_rgb
5905# define png_set_interlace_handling fn_png_set_interlace_handling
6051# define png_set_longjmp_fn fn_png_set_longjmp_fn 5906# define png_set_longjmp_fn fn_png_set_longjmp_fn
6052# define png_set_read_fn fn_png_set_read_fn 5907# define png_set_read_fn fn_png_set_read_fn
6053# define png_set_sig_bytes fn_png_set_sig_bytes 5908# define png_set_sig_bytes fn_png_set_sig_bytes
@@ -6178,7 +6033,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
6178 cairo_surface_t *surface; 6033 cairo_surface_t *surface;
6179 uint32_t *dataptr; 6034 uint32_t *dataptr;
6180#else 6035#else
6181 XImagePtr ximg, mask_img = NULL; 6036 Emacs_Pix_Container ximg, mask_img = NULL;
6182#endif 6037#endif
6183 6038
6184 /* Find out what file to load. */ 6039 /* Find out what file to load. */
@@ -6336,7 +6191,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
6336 /* png_color_16 *image_bg; */ 6191 /* png_color_16 *image_bg; */
6337 Lisp_Object specified_bg 6192 Lisp_Object specified_bg
6338 = image_spec_value (img->spec, QCbackground, NULL); 6193 = image_spec_value (img->spec, QCbackground, NULL);
6339 XColor color; 6194 Emacs_Color color;
6340 6195
6341 /* If the user specified a color, try to use it; if not, use the 6196 /* If the user specified a color, try to use it; if not, use the
6342 current frame background, ignoring any default background 6197 current frame background, ignoring any default background
@@ -6362,7 +6217,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
6362 } 6217 }
6363 } 6218 }
6364 6219
6365 /* Update info structure. */ 6220 png_set_interlace_handling (png_ptr);
6366 png_read_update_info (png_ptr, info_ptr); 6221 png_read_update_info (png_ptr, info_ptr);
6367 6222
6368 /* Get number of channels. Valid values are 1 for grayscale images 6223 /* Get number of channels. Valid values are 1 for grayscale images
@@ -6491,7 +6346,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
6491#else 6346#else
6492 /* Maybe fill in the background field while we have ximg handy. 6347 /* Maybe fill in the background field while we have ximg handy.
6493 Casting avoids a GCC warning. */ 6348 Casting avoids a GCC warning. */
6494 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); 6349 IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
6495 6350
6496 /* Put ximg into the image. */ 6351 /* Put ximg into the image. */
6497 image_put_x_image (f, img, ximg, 0); 6352 image_put_x_image (f, img, ximg, 0);
@@ -6501,7 +6356,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
6501 { 6356 {
6502 /* Fill in the background_transparent field while we have the 6357 /* Fill in the background_transparent field while we have the
6503 mask handy. Casting avoids a GCC warning. */ 6358 mask handy. Casting avoids a GCC warning. */
6504 image_background_transparent (img, f, (XImagePtr_or_DC)mask_img); 6359 image_background_transparent (img, f, (Emacs_Pix_Context)mask_img);
6505 6360
6506 image_put_x_image (f, img, mask_img, 1); 6361 image_put_x_image (f, img, mask_img, 1);
6507 } 6362 }
@@ -6538,9 +6393,6 @@ png_load (struct frame *f, struct image *img)
6538 6393
6539#if defined (HAVE_JPEG) || defined (HAVE_NS) 6394#if defined (HAVE_JPEG) || defined (HAVE_NS)
6540 6395
6541static bool jpeg_image_p (Lisp_Object object);
6542static bool jpeg_load (struct frame *f, struct image *img);
6543
6544/* Indices of image specification fields in gs_format, below. */ 6396/* Indices of image specification fields in gs_format, below. */
6545 6397
6546enum jpeg_keyword_index 6398enum jpeg_keyword_index
@@ -6575,24 +6427,6 @@ static const struct image_keyword jpeg_format[JPEG_LAST] =
6575 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 6427 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
6576}; 6428};
6577 6429
6578#if defined HAVE_NTGUI && defined WINDOWSNT
6579static bool init_jpeg_functions (void);
6580#else
6581#define init_jpeg_functions NULL
6582#endif
6583
6584/* Structure describing the image type `jpeg'. */
6585
6586static struct image_type jpeg_type =
6587{
6588 SYMBOL_INDEX (Qjpeg),
6589 jpeg_image_p,
6590 jpeg_load,
6591 image_clear_image,
6592 init_jpeg_functions,
6593 NULL
6594};
6595
6596/* Return true if OBJECT is a valid JPEG image specification. */ 6430/* Return true if OBJECT is a valid JPEG image specification. */
6597 6431
6598static bool 6432static bool
@@ -6735,7 +6569,7 @@ my_error_exit (j_common_ptr cinfo)
6735 6569
6736 6570
6737/* Init source method for JPEG data source manager. Called by 6571/* Init source method for JPEG data source manager. Called by
6738 jpeg_read_header() before any data is actually read. See 6572 jpeg_read_header before any data is actually read. See
6739 libjpeg.doc from the JPEG lib distribution. */ 6573 libjpeg.doc from the JPEG lib distribution. */
6740 6574
6741static void 6575static void
@@ -6745,7 +6579,7 @@ our_common_init_source (j_decompress_ptr cinfo)
6745 6579
6746 6580
6747/* Method to terminate data source. Called by 6581/* Method to terminate data source. Called by
6748 jpeg_finish_decompress() after all data has been processed. */ 6582 jpeg_finish_decompress after all data has been processed. */
6749 6583
6750static void 6584static void
6751our_common_term_source (j_decompress_ptr cinfo) 6585our_common_term_source (j_decompress_ptr cinfo)
@@ -6942,7 +6776,7 @@ jpeg_load_body (struct frame *f, struct image *img,
6942 int i, ir, ig, ib; 6776 int i, ir, ig, ib;
6943#ifndef USE_CAIRO 6777#ifndef USE_CAIRO
6944 unsigned long *colors; 6778 unsigned long *colors;
6945 XImagePtr ximg = NULL; 6779 Emacs_Pix_Container ximg = NULL;
6946#endif 6780#endif
6947 6781
6948 /* Open the JPEG file. */ 6782 /* Open the JPEG file. */
@@ -7132,7 +6966,7 @@ jpeg_load_body (struct frame *f, struct image *img,
7132 /* Maybe fill in the background field while we have ximg handy. */ 6966 /* Maybe fill in the background field while we have ximg handy. */
7133 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 6967 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
7134 /* Casting avoids a GCC warning. */ 6968 /* Casting avoids a GCC warning. */
7135 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); 6969 IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
7136 6970
7137 /* Put ximg into the image. */ 6971 /* Put ximg into the image. */
7138 image_put_x_image (f, img, ximg, 0); 6972 image_put_x_image (f, img, ximg, 0);
@@ -7170,9 +7004,6 @@ jpeg_load (struct frame *f, struct image *img)
7170 7004
7171#if defined (HAVE_TIFF) || defined (HAVE_NS) 7005#if defined (HAVE_TIFF) || defined (HAVE_NS)
7172 7006
7173static bool tiff_image_p (Lisp_Object object);
7174static bool tiff_load (struct frame *f, struct image *img);
7175
7176/* Indices of image specification fields in tiff_format, below. */ 7007/* Indices of image specification fields in tiff_format, below. */
7177 7008
7178enum tiff_keyword_index 7009enum tiff_keyword_index
@@ -7209,24 +7040,6 @@ static const struct image_keyword tiff_format[TIFF_LAST] =
7209 {":index", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0} 7040 {":index", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}
7210}; 7041};
7211 7042
7212#if defined HAVE_NTGUI && defined WINDOWSNT
7213static bool init_tiff_functions (void);
7214#else
7215#define init_tiff_functions NULL
7216#endif
7217
7218/* Structure describing the image type `tiff'. */
7219
7220static struct image_type tiff_type =
7221{
7222 SYMBOL_INDEX (Qtiff),
7223 tiff_image_p,
7224 tiff_load,
7225 image_clear_image,
7226 init_tiff_functions,
7227 NULL
7228};
7229
7230/* Return true if OBJECT is a valid TIFF image specification. */ 7043/* Return true if OBJECT is a valid TIFF image specification. */
7231 7044
7232static bool 7045static bool
@@ -7453,7 +7266,7 @@ tiff_load (struct frame *f, struct image *img)
7453 int width, height, x, y, count; 7266 int width, height, x, y, count;
7454 uint32 *buf; 7267 uint32 *buf;
7455 int rc; 7268 int rc;
7456 XImagePtr ximg; 7269 Emacs_Pix_Container ximg;
7457 tiff_memory_source memsrc; 7270 tiff_memory_source memsrc;
7458 Lisp_Object image; 7271 Lisp_Object image;
7459 7272
@@ -7623,7 +7436,7 @@ tiff_load (struct frame *f, struct image *img)
7623 /* Maybe fill in the background field while we have ximg handy. */ 7436 /* Maybe fill in the background field while we have ximg handy. */
7624 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 7437 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
7625 /* Casting avoids a GCC warning on W32. */ 7438 /* Casting avoids a GCC warning on W32. */
7626 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); 7439 IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
7627 7440
7628 /* Put ximg into the image. */ 7441 /* Put ximg into the image. */
7629 image_put_x_image (f, img, ximg, 0); 7442 image_put_x_image (f, img, ximg, 0);
@@ -7654,10 +7467,6 @@ tiff_load (struct frame *f, struct image *img)
7654 7467
7655#if defined (HAVE_GIF) || defined (HAVE_NS) 7468#if defined (HAVE_GIF) || defined (HAVE_NS)
7656 7469
7657static bool gif_image_p (Lisp_Object object);
7658static bool gif_load (struct frame *f, struct image *img);
7659static void gif_clear_image (struct frame *f, struct image *img);
7660
7661/* Indices of image specification fields in gif_format, below. */ 7470/* Indices of image specification fields in gif_format, below. */
7662 7471
7663enum gif_keyword_index 7472enum gif_keyword_index
@@ -7694,24 +7503,6 @@ static const struct image_keyword gif_format[GIF_LAST] =
7694 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 7503 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
7695}; 7504};
7696 7505
7697#if defined HAVE_NTGUI && defined WINDOWSNT
7698static bool init_gif_functions (void);
7699#else
7700#define init_gif_functions NULL
7701#endif
7702
7703/* Structure describing the image type `gif'. */
7704
7705static struct image_type gif_type =
7706{
7707 SYMBOL_INDEX (Qgif),
7708 gif_image_p,
7709 gif_load,
7710 gif_clear_image,
7711 init_gif_functions,
7712 NULL
7713};
7714
7715/* Free X resources of GIF image IMG which is used on frame F. */ 7506/* Free X resources of GIF image IMG which is used on frame F. */
7716 7507
7717static void 7508static void
@@ -8033,7 +7824,7 @@ gif_load (struct frame *f, struct image *img)
8033 uint32_t *data32 = (uint32_t *) cairo_image_surface_get_data (surface); 7824 uint32_t *data32 = (uint32_t *) cairo_image_surface_get_data (surface);
8034 if (STRINGP (specified_bg)) 7825 if (STRINGP (specified_bg))
8035 { 7826 {
8036 XColor color; 7827 Emacs_Color color;
8037 if (FRAME_TERMINAL (f)->defined_color_hook 7828 if (FRAME_TERMINAL (f)->defined_color_hook
8038 (f, SSDATA (specified_bg), &color, false, false)) 7829 (f, SSDATA (specified_bg), &color, false, false))
8039 { 7830 {
@@ -8049,7 +7840,7 @@ gif_load (struct frame *f, struct image *img)
8049 } 7840 }
8050#else 7841#else
8051 /* Create the X image and pixmap. */ 7842 /* Create the X image and pixmap. */
8052 XImagePtr ximg; 7843 Emacs_Pix_Container ximg;
8053 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) 7844 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
8054 { 7845 {
8055 gif_close (gif, NULL); 7846 gif_close (gif, NULL);
@@ -8279,7 +8070,7 @@ gif_load (struct frame *f, struct image *img)
8279 /* Maybe fill in the background field while we have ximg handy. */ 8070 /* Maybe fill in the background field while we have ximg handy. */
8280 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 8071 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
8281 /* Casting avoids a GCC warning. */ 8072 /* Casting avoids a GCC warning. */
8282 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); 8073 IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
8283 8074
8284 /* Put ximg into the image. */ 8075 /* Put ximg into the image. */
8285 image_put_x_image (f, img, ximg, 0); 8076 image_put_x_image (f, img, ximg, 0);
@@ -8309,10 +8100,6 @@ gif_load (struct frame *f, struct image *img)
8309 ImageMagick 8100 ImageMagick
8310***********************************************************************/ 8101***********************************************************************/
8311 8102
8312static bool imagemagick_image_p (Lisp_Object);
8313static bool imagemagick_load (struct frame *, struct image *);
8314static void imagemagick_clear_image (struct frame *, struct image *);
8315
8316/* Indices of image specification fields in imagemagick_format. */ 8103/* Indices of image specification fields in imagemagick_format. */
8317 8104
8318enum imagemagick_keyword_index 8105enum imagemagick_keyword_index
@@ -8361,25 +8148,6 @@ static struct image_keyword imagemagick_format[IMAGEMAGICK_LAST] =
8361 {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} 8148 {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
8362 }; 8149 };
8363 8150
8364#if defined HAVE_NTGUI && defined WINDOWSNT
8365static bool init_imagemagick_functions (void);
8366#else
8367#define init_imagemagick_functions NULL
8368#endif
8369
8370/* Structure describing the image type for any image handled via
8371 ImageMagick. */
8372
8373static struct image_type imagemagick_type =
8374 {
8375 SYMBOL_INDEX (Qimagemagick),
8376 imagemagick_image_p,
8377 imagemagick_load,
8378 imagemagick_clear_image,
8379 init_imagemagick_functions,
8380 NULL
8381 };
8382
8383/* Free X resources of imagemagick image IMG which is used on frame F. */ 8151/* Free X resources of imagemagick image IMG which is used on frame F. */
8384 8152
8385static void 8153static void
@@ -8686,7 +8454,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8686 size_t image_width, image_height; 8454 size_t image_width, image_height;
8687 MagickBooleanType status; 8455 MagickBooleanType status;
8688#ifndef USE_CAIRO 8456#ifndef USE_CAIRO
8689 XImagePtr ximg; 8457 Emacs_Pix_Container ximg;
8690#endif 8458#endif
8691 int x, y; 8459 int x, y;
8692 MagickWand *image_wand; 8460 MagickWand *image_wand;
@@ -8791,7 +8559,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8791 8559
8792 /* Retrieve the frame's background color, for use later. */ 8560 /* Retrieve the frame's background color, for use later. */
8793 { 8561 {
8794 XColor bgcolor; 8562 Emacs_Color bgcolor;
8795 Lisp_Object specified_bg; 8563 Lisp_Object specified_bg;
8796 8564
8797 specified_bg = image_spec_value (img->spec, QCbackground, NULL); 8565 specified_bg = image_spec_value (img->spec, QCbackground, NULL);
@@ -9157,9 +8925,6 @@ and `imagemagick-types-inhibit'. */)
9157 8925
9158/* Function prototypes. */ 8926/* Function prototypes. */
9159 8927
9160static bool svg_image_p (Lisp_Object object);
9161static bool svg_load (struct frame *f, struct image *img);
9162
9163static bool svg_load_image (struct frame *, struct image *, 8928static bool svg_load_image (struct frame *, struct image *,
9164 char *, ptrdiff_t, char *); 8929 char *, ptrdiff_t, char *);
9165 8930
@@ -9197,27 +8962,6 @@ static const struct image_keyword svg_format[SVG_LAST] =
9197 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 8962 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
9198}; 8963};
9199 8964
9200# if defined HAVE_NTGUI && defined WINDOWSNT
9201static bool init_svg_functions (void);
9202# else
9203#define init_svg_functions NULL
9204# endif
9205
9206/* Structure describing the image type `svg'. Its the same type of
9207 structure defined for all image formats, handled by emacs image
9208 functions. See struct image_type in dispextern.h. */
9209
9210static struct image_type svg_type =
9211{
9212 SYMBOL_INDEX (Qsvg),
9213 svg_image_p,
9214 svg_load,
9215 image_clear_image,
9216 init_svg_functions,
9217 NULL
9218};
9219
9220
9221/* Return true if OBJECT is a valid SVG image specification. Do 8965/* Return true if OBJECT is a valid SVG image specification. Do
9222 this by calling parse_image_spec and supplying the keywords that 8966 this by calling parse_image_spec and supplying the keywords that
9223 identify the SVG format. */ 8967 identify the SVG format. */
@@ -9248,6 +8992,11 @@ svg_image_p (Lisp_Object object)
9248 8992
9249# include <librsvg/rsvg.h> 8993# include <librsvg/rsvg.h>
9250 8994
8995/* librsvg is too old for us if it doesn't define this macro. */
8996# ifndef LIBRSVG_CHECK_VERSION
8997# define LIBRSVG_CHECK_VERSION(v, w, x) false
8998# endif
8999
9251# ifdef WINDOWSNT 9000# ifdef WINDOWSNT
9252 9001
9253/* Restore the original definition of __MINGW_MAJOR_VERSION. */ 9002/* Restore the original definition of __MINGW_MAJOR_VERSION. */
@@ -9456,7 +9205,18 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
9456 See rsvg bug 596114 - "image refs are relative to curdir, not .svg file" 9205 See rsvg bug 596114 - "image refs are relative to curdir, not .svg file"
9457 <https://gitlab.gnome.org/GNOME/librsvg/issues/33>. */ 9206 <https://gitlab.gnome.org/GNOME/librsvg/issues/33>. */
9458 if (filename) 9207 if (filename)
9459 rsvg_handle_set_base_uri(rsvg_handle, filename); 9208 rsvg_handle_set_base_uri (rsvg_handle, filename);
9209
9210 /* Suppress GCC deprecation warnings starting in librsvg 2.45.1 for
9211 rsvg_handle_write and rsvg_handle_close. FIXME: Use functions
9212 like rsvg_handle_new_from_gfile_sync on newer librsvg versions,
9213 and remove this hack. */
9214 #if GNUC_PREREQ (4, 6, 0)
9215 #pragma GCC diagnostic push
9216 #endif
9217 #if LIBRSVG_CHECK_VERSION (2, 45, 1) && GNUC_PREREQ (4, 2, 0)
9218 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
9219 #endif
9460 9220
9461 /* Parse the contents argument and fill in the rsvg_handle. */ 9221 /* Parse the contents argument and fill in the rsvg_handle. */
9462 rsvg_handle_write (rsvg_handle, (unsigned char *) contents, size, &err); 9222 rsvg_handle_write (rsvg_handle, (unsigned char *) contents, size, &err);
@@ -9467,6 +9227,10 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
9467 rsvg_handle_close (rsvg_handle, &err); 9227 rsvg_handle_close (rsvg_handle, &err);
9468 if (err) goto rsvg_error; 9228 if (err) goto rsvg_error;
9469 9229
9230 #if GNUC_PREREQ (4, 6, 0)
9231 #pragma GCC diagnostic pop
9232 #endif
9233
9470 rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); 9234 rsvg_handle_get_dimensions (rsvg_handle, &dimension_data);
9471 if (! check_image_size (f, dimension_data.width, dimension_data.height)) 9235 if (! check_image_size (f, dimension_data.width, dimension_data.height))
9472 { 9236 {
@@ -9521,7 +9285,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
9521 g_object_unref (pixbuf); 9285 g_object_unref (pixbuf);
9522#else 9286#else
9523 /* Try to create a x pixmap to hold the svg pixmap. */ 9287 /* Try to create a x pixmap to hold the svg pixmap. */
9524 XImagePtr ximg; 9288 Emacs_Pix_Container ximg;
9525 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) 9289 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
9526 { 9290 {
9527 g_object_unref (pixbuf); 9291 g_object_unref (pixbuf);
@@ -9532,7 +9296,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
9532 9296
9533 /* Handle alpha channel by combining the image with a background 9297 /* Handle alpha channel by combining the image with a background
9534 color. */ 9298 color. */
9535 XColor background; 9299 Emacs_Color background;
9536 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); 9300 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
9537 if (!STRINGP (specified_bg) 9301 if (!STRINGP (specified_bg)
9538 || !FRAME_TERMINAL (f)->defined_color_hook (f, 9302 || !FRAME_TERMINAL (f)->defined_color_hook (f,
@@ -9588,7 +9352,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
9588 9352
9589 /* Maybe fill in the background field while we have ximg handy. 9353 /* Maybe fill in the background field while we have ximg handy.
9590 Casting avoids a GCC warning. */ 9354 Casting avoids a GCC warning. */
9591 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); 9355 IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
9592 9356
9593 /* Put ximg into the image. */ 9357 /* Put ximg into the image. */
9594 image_put_x_image (f, img, ximg, 0); 9358 image_put_x_image (f, img, ximg, 0);
@@ -9621,10 +9385,6 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
9621 9385
9622#ifdef HAVE_GHOSTSCRIPT 9386#ifdef HAVE_GHOSTSCRIPT
9623 9387
9624static bool gs_image_p (Lisp_Object object);
9625static bool gs_load (struct frame *f, struct image *img);
9626static void gs_clear_image (struct frame *f, struct image *img);
9627
9628/* Indices of image specification fields in gs_format, below. */ 9388/* Indices of image specification fields in gs_format, below. */
9629 9389
9630enum gs_keyword_index 9390enum gs_keyword_index
@@ -9665,28 +9425,6 @@ static const struct image_keyword gs_format[GS_LAST] =
9665 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 9425 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
9666}; 9426};
9667 9427
9668/* Structure describing the image type `ghostscript'. */
9669
9670static struct image_type gs_type =
9671{
9672 SYMBOL_INDEX (Qpostscript),
9673 gs_image_p,
9674 gs_load,
9675 gs_clear_image,
9676 NULL,
9677 NULL
9678};
9679
9680
9681/* Free X resources of Ghostscript image IMG which is used on frame F. */
9682
9683static void
9684gs_clear_image (struct frame *f, struct image *img)
9685{
9686 image_clear_image (f, img);
9687}
9688
9689
9690/* Return true if OBJECT is a valid Ghostscript image 9428/* Return true if OBJECT is a valid Ghostscript image
9691 specification. */ 9429 specification. */
9692 9430
@@ -9812,7 +9550,7 @@ gs_load (struct frame *f, struct image *img)
9812 telling Emacs that Ghostscript has finished drawing. */ 9550 telling Emacs that Ghostscript has finished drawing. */
9813 9551
9814void 9552void
9815x_kill_gs_process (Pixmap pixmap, struct frame *f) 9553x_kill_gs_process (Emacs_Pixmap pixmap, struct frame *f)
9816{ 9554{
9817 struct image_cache *c = FRAME_IMAGE_CACHE (f); 9555 struct image_cache *c = FRAME_IMAGE_CACHE (f);
9818 ptrdiff_t i; 9556 ptrdiff_t i;
@@ -9842,7 +9580,7 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
9842 img->pixmap. */ 9580 img->pixmap. */
9843 if (x_mutable_colormap (FRAME_X_VISUAL (f))) 9581 if (x_mutable_colormap (FRAME_X_VISUAL (f)))
9844 { 9582 {
9845 XImagePtr ximg; 9583 XImage *ximg;
9846 9584
9847 block_input (); 9585 block_input ();
9848 9586
@@ -9965,87 +9703,86 @@ the library file(s) specified by `dynamic-library-alist'. */)
9965 return lookup_image_type (type) ? Qt : Qnil; 9703 return lookup_image_type (type) ? Qt : Qnil;
9966} 9704}
9967 9705
9968/* Look up image type TYPE, and return a pointer to its image_type 9706static bool
9969 structure. Return 0 if TYPE is not a known image type. */ 9707initialize_image_type (struct image_type const *type)
9970
9971static struct image_type *
9972lookup_image_type (Lisp_Object type)
9973{ 9708{
9974 /* Types pbm and xbm are built-in and always available. */ 9709#ifdef WINDOWSNT
9975 if (EQ (type, Qpbm)) 9710 Lisp_Object typesym = builtin_lisp_symbol (type->type);
9976 return define_image_type (&pbm_type); 9711 Lisp_Object tested = Fassq (typesym, Vlibrary_cache);
9977 9712 /* If we failed to load the library before, don't try again. */
9978 if (EQ (type, Qxbm)) 9713 if (CONSP (tested))
9979 return define_image_type (&xbm_type); 9714 return !NILP (XCDR (tested)) ? true : false;
9980 9715
9981#if defined (HAVE_XPM) || defined (HAVE_NS) 9716 bool (*init) (void) = type->init;
9982 if (EQ (type, Qxpm)) 9717 if (init)
9983 return define_image_type (&xpm_type); 9718 {
9719 bool type_valid = init ();
9720 Vlibrary_cache = Fcons (Fcons (typesym, type_valid ? Qt : Qnil),
9721 Vlibrary_cache);
9722 return type_valid;
9723 }
9984#endif 9724#endif
9725 return true;
9726}
9985 9727
9986#if defined (HAVE_JPEG) || defined (HAVE_NS) 9728/* Array of supported image types. */
9987 if (EQ (type, Qjpeg))
9988 return define_image_type (&jpeg_type);
9989#endif
9990 9729
9991#if defined (HAVE_TIFF) || defined (HAVE_NS) 9730static struct image_type const image_types[] =
9992 if (EQ (type, Qtiff)) 9731{
9993 return define_image_type (&tiff_type); 9732#ifdef HAVE_GHOSTSCRIPT
9733 { SYMBOL_INDEX (Qpostscript), gs_image_p, gs_load, image_clear_image },
9994#endif 9734#endif
9995 9735#ifdef HAVE_IMAGEMAGICK
9996#if defined (HAVE_GIF) || defined (HAVE_NS) 9736 { SYMBOL_INDEX (Qimagemagick), imagemagick_image_p, imagemagick_load,
9997 if (EQ (type, Qgif)) 9737 imagemagick_clear_image },
9998 return define_image_type (&gif_type);
9999#endif 9738#endif
10000 9739#ifdef HAVE_RSVG
10001#if defined (HAVE_PNG) || defined (HAVE_NS) || defined (USE_CAIRO) 9740 { SYMBOL_INDEX (Qsvg), svg_image_p, svg_load, image_clear_image,
10002 if (EQ (type, Qpng)) 9741 IMAGE_TYPE_INIT (init_svg_functions) },
10003 return define_image_type (&png_type);
10004#endif 9742#endif
10005 9743#if defined HAVE_PNG || defined HAVE_NS || defined USE_CAIRO
10006#if defined (HAVE_RSVG) 9744 { SYMBOL_INDEX (Qpng), png_image_p, png_load, image_clear_image,
10007 if (EQ (type, Qsvg)) 9745 IMAGE_TYPE_INIT (init_png_functions) },
10008 return define_image_type (&svg_type);
10009#endif 9746#endif
10010 9747#if defined HAVE_GIF || defined HAVE_NS
10011#if defined (HAVE_IMAGEMAGICK) 9748 { SYMBOL_INDEX (Qgif), gif_image_p, gif_load, gif_clear_image,
10012 if (EQ (type, Qimagemagick)) 9749 IMAGE_TYPE_INIT (init_gif_functions) },
10013 return define_image_type (&imagemagick_type);
10014#endif 9750#endif
10015 9751#if defined HAVE_TIFF || defined HAVE_NS
10016#ifdef HAVE_GHOSTSCRIPT 9752 { SYMBOL_INDEX (Qtiff), tiff_image_p, tiff_load, image_clear_image,
10017 if (EQ (type, Qpostscript)) 9753 IMAGE_TYPE_INIT (init_tiff_functions) },
10018 return define_image_type (&gs_type);
10019#endif 9754#endif
9755#if defined HAVE_JPEG || defined HAVE_NS
9756 { SYMBOL_INDEX (Qjpeg), jpeg_image_p, jpeg_load, image_clear_image,
9757 IMAGE_TYPE_INIT (init_jpeg_functions) },
9758#endif
9759#if defined HAVE_XPM || defined HAVE_NS
9760 { SYMBOL_INDEX (Qxpm), xpm_image_p, xpm_load, image_clear_image,
9761 IMAGE_TYPE_INIT (init_xpm_functions) },
9762#endif
9763 { SYMBOL_INDEX (Qxbm), xbm_image_p, xbm_load, image_clear_image },
9764 { SYMBOL_INDEX (Qpbm), pbm_image_p, pbm_load, image_clear_image },
9765};
10020 9766
10021 return NULL; 9767/* Look up image type TYPE, and return a pointer to its image_type
10022} 9768 structure. Return 0 if TYPE is not a known image type. */
10023
10024#if defined HAVE_UNEXEC && defined HAVE_WINDOW_SYSTEM
10025
10026/* Reset image_types before dumping.
10027 Called from Fdump_emacs. */
10028 9769
10029void 9770static struct image_type const *
10030reset_image_types (void) 9771lookup_image_type (Lisp_Object type)
10031{ 9772{
10032 while (image_types) 9773 for (int i = 0; i < ARRAYELTS (image_types); i++)
10033 { 9774 {
10034 struct image_type *next = image_types->next; 9775 struct image_type const *r = &image_types[i];
10035 xfree (image_types); 9776 if (EQ (type, builtin_lisp_symbol (r->type)))
10036 image_types = next; 9777 return initialize_image_type (r) ? r : NULL;
10037 } 9778 }
9779 return NULL;
10038} 9780}
10039#endif 9781
10040 9782
10041void 9783void
10042syms_of_image (void) 9784syms_of_image (void)
10043{ 9785{
10044 /* Initialize this only once; it will be reset before dumping. */
10045 /* The portable dumper will just leave it NULL, so no need to reset. */
10046 image_types = NULL;
10047 PDUMPER_IGNORE (image_types);
10048
10049 /* Must be defined now because we're going to update it below, while 9786 /* Must be defined now because we're going to update it below, while
10050 defining the supported image types. */ 9787 defining the supported image types. */
10051 DEFVAR_LISP ("image-types", Vimage_types, 9788 DEFVAR_LISP ("image-types", Vimage_types,
@@ -10096,7 +9833,7 @@ non-numeric, there is no explicit limit on the size of images. */);
10096 DEFSYM (QCmax_width, ":max-width"); 9833 DEFSYM (QCmax_width, ":max-width");
10097 DEFSYM (QCmax_height, ":max-height"); 9834 DEFSYM (QCmax_height, ":max-height");
10098#ifdef HAVE_GHOSTSCRIPT 9835#ifdef HAVE_GHOSTSCRIPT
10099 ADD_IMAGE_TYPE (Qpostscript); 9836 add_image_type (Qpostscript);
10100 DEFSYM (QCloader, ":loader"); 9837 DEFSYM (QCloader, ":loader");
10101 DEFSYM (QCpt_width, ":pt-width"); 9838 DEFSYM (QCpt_width, ":pt-width");
10102 DEFSYM (QCpt_height, ":pt-height"); 9839 DEFSYM (QCpt_height, ":pt-height");
@@ -10136,44 +9873,44 @@ non-numeric, there is no explicit limit on the size of images. */);
10136#endif 9873#endif
10137 9874
10138 DEFSYM (Qpbm, "pbm"); 9875 DEFSYM (Qpbm, "pbm");
10139 ADD_IMAGE_TYPE (Qpbm); 9876 add_image_type (Qpbm);
10140 9877
10141 DEFSYM (Qxbm, "xbm"); 9878 DEFSYM (Qxbm, "xbm");
10142 ADD_IMAGE_TYPE (Qxbm); 9879 add_image_type (Qxbm);
10143 9880
10144#if defined (HAVE_XPM) || defined (HAVE_NS) 9881#if defined (HAVE_XPM) || defined (HAVE_NS)
10145 DEFSYM (Qxpm, "xpm"); 9882 DEFSYM (Qxpm, "xpm");
10146 ADD_IMAGE_TYPE (Qxpm); 9883 add_image_type (Qxpm);
10147#endif 9884#endif
10148 9885
10149#if defined (HAVE_JPEG) || defined (HAVE_NS) 9886#if defined (HAVE_JPEG) || defined (HAVE_NS)
10150 DEFSYM (Qjpeg, "jpeg"); 9887 DEFSYM (Qjpeg, "jpeg");
10151 ADD_IMAGE_TYPE (Qjpeg); 9888 add_image_type (Qjpeg);
10152#endif 9889#endif
10153 9890
10154#if defined (HAVE_TIFF) || defined (HAVE_NS) 9891#if defined (HAVE_TIFF) || defined (HAVE_NS)
10155 DEFSYM (Qtiff, "tiff"); 9892 DEFSYM (Qtiff, "tiff");
10156 ADD_IMAGE_TYPE (Qtiff); 9893 add_image_type (Qtiff);
10157#endif 9894#endif
10158 9895
10159#if defined (HAVE_GIF) || defined (HAVE_NS) 9896#if defined (HAVE_GIF) || defined (HAVE_NS)
10160 DEFSYM (Qgif, "gif"); 9897 DEFSYM (Qgif, "gif");
10161 ADD_IMAGE_TYPE (Qgif); 9898 add_image_type (Qgif);
10162#endif 9899#endif
10163 9900
10164#if defined (HAVE_PNG) || defined (HAVE_NS) 9901#if defined (HAVE_PNG) || defined (HAVE_NS)
10165 DEFSYM (Qpng, "png"); 9902 DEFSYM (Qpng, "png");
10166 ADD_IMAGE_TYPE (Qpng); 9903 add_image_type (Qpng);
10167#endif 9904#endif
10168 9905
10169#if defined (HAVE_IMAGEMAGICK) 9906#if defined (HAVE_IMAGEMAGICK)
10170 DEFSYM (Qimagemagick, "imagemagick"); 9907 DEFSYM (Qimagemagick, "imagemagick");
10171 ADD_IMAGE_TYPE (Qimagemagick); 9908 add_image_type (Qimagemagick);
10172#endif 9909#endif
10173 9910
10174#if defined (HAVE_RSVG) 9911#if defined (HAVE_RSVG)
10175 DEFSYM (Qsvg, "svg"); 9912 DEFSYM (Qsvg, "svg");
10176 ADD_IMAGE_TYPE (Qsvg); 9913 add_image_type (Qsvg);
10177#ifdef HAVE_NTGUI 9914#ifdef HAVE_NTGUI
10178 /* Other libraries used directly by svg code. */ 9915 /* Other libraries used directly by svg code. */
10179 DEFSYM (Qgdk_pixbuf, "gdk-pixbuf"); 9916 DEFSYM (Qgdk_pixbuf, "gdk-pixbuf");