aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorJoakim Verona2010-08-17 23:19:11 +0200
committerJoakim Verona2010-08-17 23:19:11 +0200
commita8101f663e6cbff953b67b8bef33bc0171818477 (patch)
tree8f71a16188f75e91670e05379fb4de2d0136cbf4 /src/image.c
parentfe72c5b4651334677326104ec138e7cdd50f2ffe (diff)
parent489cd5bd5a0128d6c3bee49fa2c451f2927ddea9 (diff)
downloademacs-a8101f663e6cbff953b67b8bef33bc0171818477.tar.gz
emacs-a8101f663e6cbff953b67b8bef33bc0171818477.zip
merge from trunk
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c1007
1 files changed, 379 insertions, 628 deletions
diff --git a/src/image.c b/src/image.c
index 372f17348e9..e39c46b392a 100644
--- a/src/image.c
+++ b/src/image.c
@@ -126,17 +126,20 @@ typedef struct ns_bitmap_record Bitmap_Record;
126 126
127Lisp_Object Vx_bitmap_file_path; 127Lisp_Object Vx_bitmap_file_path;
128 128
129/* The symbol `postscript' identifying images of this type. */
130
131Lisp_Object Qpostscript;
129 132
130static void x_disable_image P_ ((struct frame *, struct image *)); 133static void x_disable_image (struct frame *, struct image *);
131static void x_edge_detection P_ ((struct frame *, struct image *, Lisp_Object, 134static void x_edge_detection (struct frame *, struct image *, Lisp_Object,
132 Lisp_Object)); 135 Lisp_Object);
133 136
134static void init_color_table P_ ((void)); 137static void init_color_table (void);
135static unsigned long lookup_rgb_color P_ ((struct frame *f, int r, int g, int b)); 138static unsigned long lookup_rgb_color (struct frame *f, int r, int g, int b);
136#ifdef COLOR_TABLE_SUPPORT 139#ifdef COLOR_TABLE_SUPPORT
137static void free_color_table P_ ((void)); 140static void free_color_table (void);
138static unsigned long *colors_in_color_table P_ ((int *n)); 141static unsigned long *colors_in_color_table (int *n);
139static unsigned long lookup_pixel_color P_ ((struct frame *f, unsigned long p)); 142static unsigned long lookup_pixel_color (struct frame *f, unsigned long p);
140#endif 143#endif
141 144
142/* Code to deal with bitmaps. Bitmaps are referenced by their bitmap 145/* Code to deal with bitmaps. Bitmaps are referenced by their bitmap
@@ -157,7 +160,7 @@ XGetImage (Display *display, Pixmap pixmap, int x, int y,
157 unsigned long plane_mask, int format) 160 unsigned long plane_mask, int format)
158{ 161{
159 /* TODO: not sure what this function is supposed to do.. */ 162 /* TODO: not sure what this function is supposed to do.. */
160 ns_retain_object(pixmap); 163 ns_retain_object (pixmap);
161 return pixmap; 164 return pixmap;
162} 165}
163 166
@@ -165,7 +168,7 @@ XGetImage (Display *display, Pixmap pixmap, int x, int y,
165unsigned long 168unsigned long
166XGetPixel (XImagePtr ximage, int x, int y) 169XGetPixel (XImagePtr ximage, int x, int y)
167{ 170{
168 return ns_get_pixel(ximage, x, y); 171 return ns_get_pixel (ximage, x, y);
169} 172}
170 173
171/* use with imgs created by ns_image_for_XPM; alpha set to 1; 174/* use with imgs created by ns_image_for_XPM; alpha set to 1;
@@ -173,7 +176,7 @@ XGetPixel (XImagePtr ximage, int x, int y)
173void 176void
174XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel) 177XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel)
175{ 178{
176 ns_put_pixel(ximage, x, y, pixel); 179 ns_put_pixel (ximage, x, y, pixel);
177} 180}
178#endif /* HAVE_NS */ 181#endif /* HAVE_NS */
179 182
@@ -181,26 +184,20 @@ XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel)
181/* Functions to access the contents of a bitmap, given an id. */ 184/* Functions to access the contents of a bitmap, given an id. */
182 185
183int 186int
184x_bitmap_height (f, id) 187x_bitmap_height (FRAME_PTR f, int id)
185 FRAME_PTR f;
186 int id;
187{ 188{
188 return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].height; 189 return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].height;
189} 190}
190 191
191int 192int
192x_bitmap_width (f, id) 193x_bitmap_width (FRAME_PTR f, int id)
193 FRAME_PTR f;
194 int id;
195{ 194{
196 return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].width; 195 return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].width;
197} 196}
198 197
199#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) 198#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
200int 199int
201x_bitmap_pixmap (f, id) 200x_bitmap_pixmap (FRAME_PTR f, int id)
202 FRAME_PTR f;
203 int id;
204{ 201{
205 return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap; 202 return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap;
206} 203}
@@ -208,9 +205,7 @@ x_bitmap_pixmap (f, id)
208 205
209#ifdef HAVE_X_WINDOWS 206#ifdef HAVE_X_WINDOWS
210int 207int
211x_bitmap_mask (f, id) 208x_bitmap_mask (FRAME_PTR f, int id)
212 FRAME_PTR f;
213 int id;
214{ 209{
215 return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].mask; 210 return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].mask;
216} 211}
@@ -219,8 +214,7 @@ x_bitmap_mask (f, id)
219/* Allocate a new bitmap record. Returns index of new record. */ 214/* Allocate a new bitmap record. Returns index of new record. */
220 215
221static int 216static int
222x_allocate_bitmap_record (f) 217x_allocate_bitmap_record (FRAME_PTR f)
223 FRAME_PTR f;
224{ 218{
225 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 219 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
226 int i; 220 int i;
@@ -251,9 +245,7 @@ x_allocate_bitmap_record (f)
251/* Add one reference to the reference count of the bitmap with id ID. */ 245/* Add one reference to the reference count of the bitmap with id ID. */
252 246
253void 247void
254x_reference_bitmap (f, id) 248x_reference_bitmap (FRAME_PTR f, int id)
255 FRAME_PTR f;
256 int id;
257{ 249{
258 ++FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].refcount; 250 ++FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].refcount;
259} 251}
@@ -261,10 +253,7 @@ x_reference_bitmap (f, id)
261/* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */ 253/* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */
262 254
263int 255int
264x_create_bitmap_from_data (f, bits, width, height) 256x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsigned int height)
265 struct frame *f;
266 char *bits;
267 unsigned int width, height;
268{ 257{
269 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 258 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
270 int id; 259 int id;
@@ -288,7 +277,7 @@ x_create_bitmap_from_data (f, bits, width, height)
288#endif /* HAVE_NTGUI */ 277#endif /* HAVE_NTGUI */
289 278
290#ifdef HAVE_NS 279#ifdef HAVE_NS
291 void *bitmap = ns_image_from_XBM(bits, width, height); 280 void *bitmap = ns_image_from_XBM (bits, width, height);
292 if (!bitmap) 281 if (!bitmap)
293 return -1; 282 return -1;
294#endif 283#endif
@@ -323,9 +312,7 @@ x_create_bitmap_from_data (f, bits, width, height)
323/* Create bitmap from file FILE for frame F. */ 312/* Create bitmap from file FILE for frame F. */
324 313
325int 314int
326x_create_bitmap_from_file (f, file) 315x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
327 struct frame *f;
328 Lisp_Object file;
329{ 316{
330 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 317 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
331 318
@@ -335,7 +322,7 @@ x_create_bitmap_from_file (f, file)
335 322
336#ifdef HAVE_NS 323#ifdef HAVE_NS
337 int id; 324 int id;
338 void *bitmap = ns_image_from_file(file); 325 void *bitmap = ns_image_from_file (file);
339 326
340 if (!bitmap) 327 if (!bitmap)
341 return -1; 328 return -1;
@@ -346,8 +333,8 @@ x_create_bitmap_from_file (f, file)
346 dpyinfo->bitmaps[id - 1].refcount = 1; 333 dpyinfo->bitmaps[id - 1].refcount = 1;
347 dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1); 334 dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1);
348 dpyinfo->bitmaps[id - 1].depth = 1; 335 dpyinfo->bitmaps[id - 1].depth = 1;
349 dpyinfo->bitmaps[id - 1].height = ns_image_width(bitmap); 336 dpyinfo->bitmaps[id - 1].height = ns_image_width (bitmap);
350 dpyinfo->bitmaps[id - 1].width = ns_image_height(bitmap); 337 dpyinfo->bitmaps[id - 1].width = ns_image_height (bitmap);
351 strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file)); 338 strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file));
352 return id; 339 return id;
353#endif 340#endif
@@ -402,9 +389,7 @@ x_create_bitmap_from_file (f, file)
402/* Free bitmap B. */ 389/* Free bitmap B. */
403 390
404static void 391static void
405free_bitmap_record (dpyinfo, bm) 392free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record *bm)
406 Display_Info *dpyinfo;
407 Bitmap_Record *bm;
408{ 393{
409#ifdef HAVE_X_WINDOWS 394#ifdef HAVE_X_WINDOWS
410 XFreePixmap (dpyinfo->display, bm->pixmap); 395 XFreePixmap (dpyinfo->display, bm->pixmap);
@@ -417,7 +402,7 @@ free_bitmap_record (dpyinfo, bm)
417#endif /* HAVE_NTGUI */ 402#endif /* HAVE_NTGUI */
418 403
419#ifdef HAVE_NS 404#ifdef HAVE_NS
420 ns_release_object(bm->img); 405 ns_release_object (bm->img);
421#endif 406#endif
422 407
423 if (bm->file) 408 if (bm->file)
@@ -430,9 +415,7 @@ free_bitmap_record (dpyinfo, bm)
430/* Remove reference to bitmap with id number ID. */ 415/* Remove reference to bitmap with id number ID. */
431 416
432void 417void
433x_destroy_bitmap (f, id) 418x_destroy_bitmap (FRAME_PTR f, int id)
434 FRAME_PTR f;
435 int id;
436{ 419{
437 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 420 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
438 421
@@ -452,8 +435,7 @@ x_destroy_bitmap (f, id)
452/* Free all the bitmaps for the display specified by DPYINFO. */ 435/* Free all the bitmaps for the display specified by DPYINFO. */
453 436
454void 437void
455x_destroy_all_bitmaps (dpyinfo) 438x_destroy_all_bitmaps (Display_Info *dpyinfo)
456 Display_Info *dpyinfo;
457{ 439{
458 int i; 440 int i;
459 Bitmap_Record *bm = dpyinfo->bitmaps; 441 Bitmap_Record *bm = dpyinfo->bitmaps;
@@ -471,25 +453,23 @@ x_destroy_all_bitmaps (dpyinfo)
471/* Useful functions defined in the section 453/* Useful functions defined in the section
472 `Image type independent image structures' below. */ 454 `Image type independent image structures' below. */
473 455
474static unsigned long four_corners_best P_ ((XImagePtr ximg, 456static unsigned long four_corners_best (XImagePtr ximg,
475 int *corners, 457 int *corners,
476 unsigned long width, 458 unsigned long width,
477 unsigned long height)); 459 unsigned long height);
478 460
479static int x_create_x_image_and_pixmap P_ ((struct frame *f, int width, int height, 461static int x_create_x_image_and_pixmap (struct frame *f, int width, int height,
480 int depth, XImagePtr *ximg, 462 int depth, XImagePtr *ximg,
481 Pixmap *pixmap)); 463 Pixmap *pixmap);
482 464
483static void x_destroy_x_image P_ ((XImagePtr ximg)); 465static void x_destroy_x_image (XImagePtr ximg);
484 466
485 467
486/* Create a mask of a bitmap. Note is this not a perfect mask. 468/* Create a mask of a bitmap. Note is this not a perfect mask.
487 It's nicer with some borders in this context */ 469 It's nicer with some borders in this context */
488 470
489int 471int
490x_create_bitmap_mask (f, id) 472x_create_bitmap_mask (struct frame *f, int id)
491 struct frame *f;
492 int id;
493{ 473{
494 Pixmap pixmap, mask; 474 Pixmap pixmap, mask;
495 XImagePtr ximg, mask_img; 475 XImagePtr ximg, mask_img;
@@ -601,9 +581,6 @@ Lisp_Object Qxbm;
601 581
602/* Keywords. */ 582/* Keywords. */
603 583
604extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile;
605extern Lisp_Object QCdata, QCtype;
606extern Lisp_Object Qcenter;
607Lisp_Object QCascent, QCmargin, QCrelief, Qcount, Qextension_data; 584Lisp_Object QCascent, QCmargin, QCrelief, Qcount, Qextension_data;
608Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask; 585Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask;
609Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask, QCgeometry, QCcrop, QCrotation; 586Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask, QCgeometry, QCcrop, QCrotation;
@@ -619,13 +596,13 @@ Lisp_Object Vimage_cache_eviction_delay;
619 596
620/* Function prototypes. */ 597/* Function prototypes. */
621 598
622static Lisp_Object define_image_type P_ ((struct image_type *type, int loaded)); 599static Lisp_Object define_image_type (struct image_type *type, int loaded);
623static struct image_type *lookup_image_type P_ ((Lisp_Object symbol)); 600static struct image_type *lookup_image_type (Lisp_Object symbol);
624static void image_error P_ ((char *format, Lisp_Object, Lisp_Object)); 601static void image_error (const char *format, Lisp_Object, Lisp_Object);
625static void x_laplace P_ ((struct frame *, struct image *)); 602static void x_laplace (struct frame *, struct image *);
626static void x_emboss P_ ((struct frame *, struct image *)); 603static void x_emboss (struct frame *, struct image *);
627static int x_build_heuristic_mask P_ ((struct frame *, struct image *, 604static int x_build_heuristic_mask (struct frame *, struct image *,
628 Lisp_Object)); 605 Lisp_Object);
629 606
630#define CACHE_IMAGE_TYPE(type, status) \ 607#define CACHE_IMAGE_TYPE(type, status) \
631 do { Vimage_type_cache = Fcons (Fcons (type, status), Vimage_type_cache); } while (0) 608 do { Vimage_type_cache = Fcons (Fcons (type, status), Vimage_type_cache); } while (0)
@@ -637,9 +614,7 @@ static int x_build_heuristic_mask P_ ((struct frame *, struct image *,
637 image_types and caches the loading status of TYPE. */ 614 image_types and caches the loading status of TYPE. */
638 615
639static Lisp_Object 616static Lisp_Object
640define_image_type (type, loaded) 617define_image_type (struct image_type *type, int loaded)
641 struct image_type *type;
642 int loaded;
643{ 618{
644 Lisp_Object success; 619 Lisp_Object success;
645 620
@@ -650,7 +625,7 @@ define_image_type (type, loaded)
650 /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. 625 /* Make a copy of TYPE to avoid a bus error in a dumped Emacs.
651 The initialized data segment is read-only. */ 626 The initialized data segment is read-only. */
652 struct image_type *p = (struct image_type *) xmalloc (sizeof *p); 627 struct image_type *p = (struct image_type *) xmalloc (sizeof *p);
653 bcopy (type, p, sizeof *p); 628 memcpy (p, type, sizeof *p);
654 p->next = image_types; 629 p->next = image_types;
655 image_types = p; 630 image_types = p;
656 success = Qt; 631 success = Qt;
@@ -665,8 +640,7 @@ define_image_type (type, loaded)
665 structure. Value is null if SYMBOL is not a known image type. */ 640 structure. Value is null if SYMBOL is not a known image type. */
666 641
667static INLINE struct image_type * 642static INLINE struct image_type *
668lookup_image_type (symbol) 643lookup_image_type (Lisp_Object symbol)
669 Lisp_Object symbol;
670{ 644{
671 struct image_type *type; 645 struct image_type *type;
672 646
@@ -690,8 +664,7 @@ lookup_image_type (symbol)
690 image type. */ 664 image type. */
691 665
692int 666int
693valid_image_p (object) 667valid_image_p (Lisp_Object object)
694 Lisp_Object object;
695{ 668{
696 int valid_p = 0; 669 int valid_p = 0;
697 670
@@ -726,9 +699,7 @@ valid_image_p (object)
726 therefore simply displays a message. */ 699 therefore simply displays a message. */
727 700
728static void 701static void
729image_error (format, arg1, arg2) 702image_error (const char *format, Lisp_Object arg1, Lisp_Object arg2)
730 char *format;
731 Lisp_Object arg1, arg2;
732{ 703{
733 add_to_log (format, arg1, arg2); 704 add_to_log (format, arg1, arg2);
734} 705}
@@ -760,7 +731,7 @@ enum image_value_type
760struct image_keyword 731struct image_keyword
761{ 732{
762 /* Name of keyword. */ 733 /* Name of keyword. */
763 char *name; 734 const char *name;
764 735
765 /* The type of value allowed. */ 736 /* The type of value allowed. */
766 enum image_value_type type; 737 enum image_value_type type;
@@ -776,9 +747,9 @@ struct image_keyword
776}; 747};
777 748
778 749
779static int parse_image_spec P_ ((Lisp_Object, struct image_keyword *, 750static int parse_image_spec (Lisp_Object, struct image_keyword *,
780 int, Lisp_Object)); 751 int, Lisp_Object);
781static Lisp_Object image_spec_value P_ ((Lisp_Object, Lisp_Object, int *)); 752static Lisp_Object image_spec_value (Lisp_Object, Lisp_Object, int *);
782 753
783 754
784/* Parse image spec SPEC according to KEYWORDS. A valid image spec 755/* Parse image spec SPEC according to KEYWORDS. A valid image spec
@@ -788,11 +759,8 @@ static Lisp_Object image_spec_value P_ ((Lisp_Object, Lisp_Object, int *));
788 allowed keyword/value pairs. Value is non-zero if SPEC is valid. */ 759 allowed keyword/value pairs. Value is non-zero if SPEC is valid. */
789 760
790static int 761static int
791parse_image_spec (spec, keywords, nkeywords, type) 762parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
792 Lisp_Object spec; 763 int nkeywords, Lisp_Object type)
793 struct image_keyword *keywords;
794 int nkeywords;
795 Lisp_Object type;
796{ 764{
797 int i; 765 int i;
798 Lisp_Object plist; 766 Lisp_Object plist;
@@ -928,9 +896,7 @@ parse_image_spec (spec, keywords, nkeywords, type)
928 to 1 if KEY was found in SPEC, set it to 0 otherwise. */ 896 to 1 if KEY was found in SPEC, set it to 0 otherwise. */
929 897
930static Lisp_Object 898static Lisp_Object
931image_spec_value (spec, key, found) 899image_spec_value (Lisp_Object spec, Lisp_Object key, int *found)
932 Lisp_Object spec, key;
933 int *found;
934{ 900{
935 Lisp_Object tail; 901 Lisp_Object tail;
936 902
@@ -956,12 +922,11 @@ image_spec_value (spec, key, found)
956 922
957DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0, 923DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0,
958 doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT). 924 doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT).
959 PIXELS non-nil means return the size in pixels, otherwise return the 925PIXELS non-nil means return the size in pixels, otherwise return the
960 size in canonical character units. 926size in canonical character units.
961 FRAME is the frame on which the image will be displayed. FRAME nil 927FRAME is the frame on which the image will be displayed. FRAME nil
962 or omitted means use the selected frame. */) 928or omitted means use the selected frame. */)
963 (spec, pixels, frame) 929 (Lisp_Object spec, Lisp_Object pixels, Lisp_Object frame)
964 Lisp_Object spec, pixels, frame;
965{ 930{
966 Lisp_Object size; 931 Lisp_Object size;
967 932
@@ -989,10 +954,9 @@ DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0,
989 954
990DEFUN ("image-mask-p", Fimage_mask_p, Simage_mask_p, 1, 2, 0, 955DEFUN ("image-mask-p", Fimage_mask_p, Simage_mask_p, 1, 2, 0,
991 doc: /* Return t if image SPEC has a mask bitmap. 956 doc: /* Return t if image SPEC has a mask bitmap.
992 FRAME is the frame on which the image will be displayed. FRAME nil 957FRAME is the frame on which the image will be displayed. FRAME nil
993 or omitted means use the selected frame. */) 958or omitted means use the selected frame. */)
994 (spec, frame) 959 (Lisp_Object spec, Lisp_Object frame)
995 Lisp_Object spec, frame;
996{ 960{
997 Lisp_Object mask; 961 Lisp_Object mask;
998 962
@@ -1013,10 +977,9 @@ DEFUN ("image-mask-p", Fimage_mask_p, Simage_mask_p, 1, 2, 0,
1013 977
1014DEFUN ("image-metadata", Fimage_metadata, Simage_metadata, 1, 2, 0, 978DEFUN ("image-metadata", Fimage_metadata, Simage_metadata, 1, 2, 0,
1015 doc: /* Return metadata for image SPEC. 979 doc: /* Return metadata for image SPEC.
1016 FRAME is the frame on which the image will be displayed. FRAME nil 980FRAME is the frame on which the image will be displayed. FRAME nil
1017 or omitted means use the selected frame. */) 981or omitted means use the selected frame. */)
1018 (spec, frame) 982 (Lisp_Object spec, Lisp_Object frame)
1019 Lisp_Object spec, frame;
1020{ 983{
1021 Lisp_Object ext; 984 Lisp_Object ext;
1022 985
@@ -1037,9 +1000,9 @@ DEFUN ("image-metadata", Fimage_metadata, Simage_metadata, 1, 2, 0,
1037 Image type independent image structures 1000 Image type independent image structures
1038***********************************************************************/ 1001***********************************************************************/
1039 1002
1040static struct image *make_image P_ ((Lisp_Object spec, unsigned hash)); 1003static struct image *make_image (Lisp_Object spec, unsigned hash);
1041static void free_image P_ ((struct frame *f, struct image *img)); 1004static void free_image (struct frame *f, struct image *img);
1042static int check_image_size P_ ((struct frame *f, int width, int height)); 1005static int check_image_size (struct frame *f, int width, int height);
1043 1006
1044#define MAX_IMAGE_SIZE 6.0 1007#define MAX_IMAGE_SIZE 6.0
1045Lisp_Object Vmax_image_size; 1008Lisp_Object Vmax_image_size;
@@ -1048,15 +1011,13 @@ Lisp_Object Vmax_image_size;
1048 SPEC. SPEC has a hash value of HASH. */ 1011 SPEC. SPEC has a hash value of HASH. */
1049 1012
1050static struct image * 1013static struct image *
1051make_image (spec, hash) 1014make_image (Lisp_Object spec, unsigned int hash)
1052 Lisp_Object spec;
1053 unsigned hash;
1054{ 1015{
1055 struct image *img = (struct image *) xmalloc (sizeof *img); 1016 struct image *img = (struct image *) xmalloc (sizeof *img);
1056 Lisp_Object file = image_spec_value (spec, QCfile, NULL); 1017 Lisp_Object file = image_spec_value (spec, QCfile, NULL);
1057 1018
1058 xassert (valid_image_p (spec)); 1019 xassert (valid_image_p (spec));
1059 bzero (img, sizeof *img); 1020 memset (img, 0, sizeof *img);
1060 img->dependencies = NILP (file) ? Qnil : list1 (file); 1021 img->dependencies = NILP (file) ? Qnil : list1 (file);
1061 img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); 1022 img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
1062 xassert (img->type != NULL); 1023 xassert (img->type != NULL);
@@ -1072,9 +1033,7 @@ make_image (spec, hash)
1072/* Free image IMG which was used on frame F, including its resources. */ 1033/* Free image IMG which was used on frame F, including its resources. */
1073 1034
1074static void 1035static void
1075free_image (f, img) 1036free_image (struct frame *f, struct image *img)
1076 struct frame *f;
1077 struct image *img;
1078{ 1037{
1079 if (img) 1038 if (img)
1080 { 1039 {
@@ -1094,6 +1053,10 @@ free_image (f, img)
1094 /* Free resources, then free IMG. */ 1053 /* Free resources, then free IMG. */
1095 img->type->free (f, img); 1054 img->type->free (f, img);
1096 xfree (img); 1055 xfree (img);
1056
1057 /* As display glyphs may still be referring to the image ID, we
1058 must garbage the frame (Bug#6426). */
1059 SET_FRAME_GARBAGED (f);
1097 } 1060 }
1098} 1061}
1099 1062
@@ -1101,10 +1064,7 @@ free_image (f, img)
1101 otherwise, return 0. */ 1064 otherwise, return 0. */
1102 1065
1103int 1066int
1104check_image_size (f, width, height) 1067check_image_size (struct frame *f, int width, int height)
1105 struct frame *f;
1106 int width;
1107 int height;
1108{ 1068{
1109 int w, h; 1069 int w, h;
1110 1070
@@ -1135,9 +1095,7 @@ check_image_size (f, width, height)
1135 drawing an image. */ 1095 drawing an image. */
1136 1096
1137void 1097void
1138prepare_image_for_display (f, img) 1098prepare_image_for_display (struct frame *f, struct image *img)
1139 struct frame *f;
1140 struct image *img;
1141{ 1099{
1142 EMACS_TIME t; 1100 EMACS_TIME t;
1143 1101
@@ -1157,10 +1115,7 @@ prepare_image_for_display (f, img)
1157 drawn in face FACE. */ 1115 drawn in face FACE. */
1158 1116
1159int 1117int
1160image_ascent (img, face, slice) 1118image_ascent (struct image *img, struct face *face, struct glyph_slice *slice)
1161 struct image *img;
1162 struct face *face;
1163 struct glyph_slice *slice;
1164{ 1119{
1165 int height; 1120 int height;
1166 int ascent; 1121 int ascent;
@@ -1206,10 +1161,8 @@ image_ascent (img, face, slice)
1206 On W32, XIMG is assumed to a device context with the bitmap selected. */ 1161 On W32, XIMG is assumed to a device context with the bitmap selected. */
1207 1162
1208static RGB_PIXEL_COLOR 1163static RGB_PIXEL_COLOR
1209four_corners_best (ximg, corners, width, height) 1164four_corners_best (XImagePtr_or_DC ximg, int *corners,
1210 XImagePtr_or_DC ximg; 1165 unsigned long width, unsigned long height)
1211 int *corners;
1212 unsigned long width, height;
1213{ 1166{
1214 RGB_PIXEL_COLOR corner_pixels[4], best; 1167 RGB_PIXEL_COLOR corner_pixels[4], best;
1215 int i, best_count; 1168 int i, best_count;
@@ -1258,11 +1211,11 @@ four_corners_best (ximg, corners, width, height)
1258 1211
1259#elif defined (HAVE_NS) 1212#elif defined (HAVE_NS)
1260 1213
1261#define Destroy_Image(ximg, dummy) \ 1214#define Destroy_Image(ximg, dummy) \
1262 ns_release_object(ximg) 1215 ns_release_object (ximg)
1263 1216
1264#define Free_Pixmap(display, pixmap) \ 1217#define Free_Pixmap(display, pixmap) \
1265 ns_release_object(pixmap) 1218 ns_release_object (pixmap)
1266 1219
1267#else 1220#else
1268 1221
@@ -1281,10 +1234,7 @@ four_corners_best (ximg, corners, width, height)
1281 use for the heuristic. */ 1234 use for the heuristic. */
1282 1235
1283RGB_PIXEL_COLOR 1236RGB_PIXEL_COLOR
1284image_background (img, f, ximg) 1237image_background (struct image *img, struct frame *f, XImagePtr_or_DC ximg)
1285 struct image *img;
1286 struct frame *f;
1287 XImagePtr_or_DC ximg;
1288{ 1238{
1289 if (! img->background_valid) 1239 if (! img->background_valid)
1290 /* IMG doesn't have a background yet, try to guess a reasonable value. */ 1240 /* IMG doesn't have a background yet, try to guess a reasonable value. */
@@ -1323,10 +1273,7 @@ image_background (img, f, ximg)
1323 existing XImage object to use for the heuristic. */ 1273 existing XImage object to use for the heuristic. */
1324 1274
1325int 1275int
1326image_background_transparent (img, f, mask) 1276image_background_transparent (struct image *img, struct frame *f, XImagePtr_or_DC mask)
1327 struct image *img;
1328 struct frame *f;
1329 XImagePtr_or_DC mask;
1330{ 1277{
1331 if (! img->background_transparent_valid) 1278 if (! img->background_transparent_valid)
1332 /* IMG doesn't have a background yet, try to guess a reasonable value. */ 1279 /* IMG doesn't have a background yet, try to guess a reasonable value. */
@@ -1371,13 +1318,13 @@ image_background_transparent (img, f, mask)
1371 Helper functions for X image types 1318 Helper functions for X image types
1372***********************************************************************/ 1319***********************************************************************/
1373 1320
1374static void x_clear_image_1 P_ ((struct frame *, struct image *, int, 1321static void x_clear_image_1 (struct frame *, struct image *, int,
1375 int, int)); 1322 int, int);
1376static void x_clear_image P_ ((struct frame *f, struct image *img)); 1323static void x_clear_image (struct frame *f, struct image *img);
1377static unsigned long x_alloc_image_color P_ ((struct frame *f, 1324static unsigned long x_alloc_image_color (struct frame *f,
1378 struct image *img, 1325 struct image *img,
1379 Lisp_Object color_name, 1326 Lisp_Object color_name,
1380 unsigned long dflt)); 1327 unsigned long dflt);
1381 1328
1382 1329
1383/* Clear X resources of image IMG on frame F. PIXMAP_P non-zero means 1330/* Clear X resources of image IMG on frame F. PIXMAP_P non-zero means
@@ -1386,10 +1333,8 @@ static unsigned long x_alloc_image_color P_ ((struct frame *f,
1386 the image, if any. */ 1333 the image, if any. */
1387 1334
1388static void 1335static void
1389x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p) 1336x_clear_image_1 (struct frame *f, struct image *img, int pixmap_p, int mask_p,
1390 struct frame *f; 1337 int colors_p)
1391 struct image *img;
1392 int pixmap_p, mask_p, colors_p;
1393{ 1338{
1394 if (pixmap_p && img->pixmap) 1339 if (pixmap_p && img->pixmap)
1395 { 1340 {
@@ -1422,9 +1367,7 @@ x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p)
1422/* Free X resources of image IMG which is used on frame F. */ 1367/* Free X resources of image IMG which is used on frame F. */
1423 1368
1424static void 1369static void
1425x_clear_image (f, img) 1370x_clear_image (struct frame *f, struct image *img)
1426 struct frame *f;
1427 struct image *img;
1428{ 1371{
1429 BLOCK_INPUT; 1372 BLOCK_INPUT;
1430 x_clear_image_1 (f, img, 1, 1, 1); 1373 x_clear_image_1 (f, img, 1, 1, 1);
@@ -1438,11 +1381,8 @@ x_clear_image (f, img)
1438 color. */ 1381 color. */
1439 1382
1440static unsigned long 1383static unsigned long
1441x_alloc_image_color (f, img, color_name, dflt) 1384x_alloc_image_color (struct frame *f, struct image *img, Lisp_Object color_name,
1442 struct frame *f; 1385 unsigned long dflt)
1443 struct image *img;
1444 Lisp_Object color_name;
1445 unsigned long dflt;
1446{ 1386{
1447 XColor color; 1387 XColor color;
1448 unsigned long result; 1388 unsigned long result;
@@ -1472,25 +1412,25 @@ x_alloc_image_color (f, img, color_name, dflt)
1472 Image Cache 1412 Image Cache
1473***********************************************************************/ 1413***********************************************************************/
1474 1414
1475static struct image *search_image_cache P_ ((struct frame *, Lisp_Object, unsigned)); 1415static struct image *search_image_cache (struct frame *, Lisp_Object, unsigned);
1476static void cache_image P_ ((struct frame *f, struct image *img)); 1416static void cache_image (struct frame *f, struct image *img);
1477static void postprocess_image P_ ((struct frame *, struct image *)); 1417static void postprocess_image (struct frame *, struct image *);
1478 1418
1479/* Return a new, initialized image cache that is allocated from the 1419/* Return a new, initialized image cache that is allocated from the
1480 heap. Call free_image_cache to free an image cache. */ 1420 heap. Call free_image_cache to free an image cache. */
1481 1421
1482struct image_cache * 1422struct image_cache *
1483make_image_cache () 1423make_image_cache (void)
1484{ 1424{
1485 struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c); 1425 struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);
1486 int size; 1426 int size;
1487 1427
1488 bzero (c, sizeof *c); 1428 memset (c, 0, sizeof *c);
1489 c->size = 50; 1429 c->size = 50;
1490 c->images = (struct image **) xmalloc (c->size * sizeof *c->images); 1430 c->images = (struct image **) xmalloc (c->size * sizeof *c->images);
1491 size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; 1431 size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
1492 c->buckets = (struct image **) xmalloc (size); 1432 c->buckets = (struct image **) xmalloc (size);
1493 bzero (c->buckets, size); 1433 memset (c->buckets, 0, size);
1494 return c; 1434 return c;
1495} 1435}
1496 1436
@@ -1498,10 +1438,7 @@ make_image_cache ()
1498/* Find an image matching SPEC in the cache, and return it. If no 1438/* Find an image matching SPEC in the cache, and return it. If no
1499 image is found, return NULL. */ 1439 image is found, return NULL. */
1500static struct image * 1440static struct image *
1501search_image_cache (f, spec, hash) 1441search_image_cache (struct frame *f, Lisp_Object spec, unsigned int hash)
1502 struct frame *f;
1503 Lisp_Object spec;
1504 unsigned hash;
1505{ 1442{
1506 struct image *img; 1443 struct image *img;
1507 struct image_cache *c = FRAME_IMAGE_CACHE (f); 1444 struct image_cache *c = FRAME_IMAGE_CACHE (f);
@@ -1534,9 +1471,7 @@ search_image_cache (f, spec, hash)
1534/* Search frame F for an image with spec SPEC, and free it. */ 1471/* Search frame F for an image with spec SPEC, and free it. */
1535 1472
1536static void 1473static void
1537uncache_image (f, spec) 1474uncache_image (struct frame *f, Lisp_Object spec)
1538 struct frame *f;
1539 Lisp_Object spec;
1540{ 1475{
1541 struct image *img = search_image_cache (f, spec, sxhash (spec, 0)); 1476 struct image *img = search_image_cache (f, spec, sxhash (spec, 0));
1542 if (img) 1477 if (img)
@@ -1548,8 +1483,7 @@ uncache_image (f, spec)
1548 caches. */ 1483 caches. */
1549 1484
1550void 1485void
1551free_image_cache (f) 1486free_image_cache (struct frame *f)
1552 struct frame *f;
1553{ 1487{
1554 struct image_cache *c = FRAME_IMAGE_CACHE (f); 1488 struct image_cache *c = FRAME_IMAGE_CACHE (f);
1555 if (c) 1489 if (c)
@@ -1673,12 +1607,11 @@ clear_image_caches (Lisp_Object filter)
1673DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache, 1607DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache,
1674 0, 1, 0, 1608 0, 1, 0,
1675 doc: /* Clear the image cache. 1609 doc: /* Clear the image cache.
1676 FILTER nil or a frame means clear all images in the selected frame. 1610FILTER nil or a frame means clear all images in the selected frame.
1677 FILTER t means clear the image caches of all frames. 1611FILTER t means clear the image caches of all frames.
1678 Anything else, means only clear those images which refer to FILTER, 1612Anything else, means only clear those images which refer to FILTER,
1679 which is then usually a filename. */) 1613which is then usually a filename. */)
1680 (filter) 1614 (Lisp_Object filter)
1681 Lisp_Object filter;
1682{ 1615{
1683 if (!(EQ (filter, Qnil) || FRAMEP (filter))) 1616 if (!(EQ (filter, Qnil) || FRAMEP (filter)))
1684 clear_image_caches (filter); 1617 clear_image_caches (filter);
@@ -1696,10 +1629,9 @@ DEFUN ("image-flush", Fimage_flush, Simage_flush,
1696 an image file, the next redisplay of this image will read from the 1629 an image file, the next redisplay of this image will read from the
1697 current contents of that file. 1630 current contents of that file.
1698 1631
1699 FRAME nil or omitted means use the selected frame. 1632FRAME nil or omitted means use the selected frame.
1700 FRAME t means refresh the image on all frames. */) 1633FRAME t means refresh the image on all frames. */)
1701 (spec, frame) 1634 (Lisp_Object spec, Lisp_Object frame)
1702 Lisp_Object spec, frame;
1703{ 1635{
1704 if (!valid_image_p (spec)) 1636 if (!valid_image_p (spec))
1705 error ("Invalid image specification"); 1637 error ("Invalid image specification");
@@ -1725,9 +1657,7 @@ DEFUN ("image-flush", Fimage_flush, Simage_flush,
1725 by the image's specification, */ 1657 by the image's specification, */
1726 1658
1727static void 1659static void
1728postprocess_image (f, img) 1660postprocess_image (struct frame *f, struct image *img)
1729 struct frame *f;
1730 struct image *img;
1731{ 1661{
1732 /* Manipulation of the image's mask. */ 1662 /* Manipulation of the image's mask. */
1733 if (img->pixmap) 1663 if (img->pixmap)
@@ -1800,9 +1730,7 @@ postprocess_image (f, img)
1800 SPEC must be a valid Lisp image specification (see valid_image_p). */ 1730 SPEC must be a valid Lisp image specification (see valid_image_p). */
1801 1731
1802int 1732int
1803lookup_image (f, spec) 1733lookup_image (struct frame *f, Lisp_Object spec)
1804 struct frame *f;
1805 Lisp_Object spec;
1806{ 1734{
1807 struct image_cache *c; 1735 struct image_cache *c;
1808 struct image *img; 1736 struct image *img;
@@ -1831,8 +1759,6 @@ lookup_image (f, spec)
1831 /* If not found, create a new image and cache it. */ 1759 /* If not found, create a new image and cache it. */
1832 if (img == NULL) 1760 if (img == NULL)
1833 { 1761 {
1834 extern Lisp_Object Qpostscript;
1835
1836 BLOCK_INPUT; 1762 BLOCK_INPUT;
1837 img = make_image (spec, hash); 1763 img = make_image (spec, hash);
1838 cache_image (f, img); 1764 cache_image (f, img);
@@ -1922,9 +1848,7 @@ lookup_image (f, spec)
1922/* Cache image IMG in the image cache of frame F. */ 1848/* Cache image IMG in the image cache of frame F. */
1923 1849
1924static void 1850static void
1925cache_image (f, img) 1851cache_image (struct frame *f, struct image *img)
1926 struct frame *f;
1927 struct image *img;
1928{ 1852{
1929 struct image_cache *c = FRAME_IMAGE_CACHE (f); 1853 struct image_cache *c = FRAME_IMAGE_CACHE (f);
1930 int i; 1854 int i;
@@ -1964,8 +1888,7 @@ cache_image (f, img)
1964/* Mark Lisp objects in image IMG. */ 1888/* Mark Lisp objects in image IMG. */
1965 1889
1966static void 1890static void
1967mark_image (img) 1891mark_image (struct image *img)
1968 struct image *img;
1969{ 1892{
1970 mark_object (img->spec); 1893 mark_object (img->spec);
1971 mark_object (img->dependencies); 1894 mark_object (img->dependencies);
@@ -2033,10 +1956,10 @@ w32_delayed_load (Lisp_Object libraries, Lisp_Object type)
2033 1956
2034#endif /* HAVE_NTGUI */ 1957#endif /* HAVE_NTGUI */
2035 1958
2036static int x_create_x_image_and_pixmap P_ ((struct frame *, int, int, int, 1959static int x_create_x_image_and_pixmap (struct frame *, int, int, int,
2037 XImagePtr *, Pixmap *)); 1960 XImagePtr *, Pixmap *);
2038static void x_destroy_x_image P_ ((XImagePtr)); 1961static void x_destroy_x_image (XImagePtr);
2039static void x_put_x_image P_ ((struct frame *, XImagePtr, Pixmap, int, int)); 1962static void x_put_x_image (struct frame *, XImagePtr, Pixmap, int, int);
2040 1963
2041 1964
2042/* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on 1965/* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on
@@ -2049,11 +1972,8 @@ static void x_put_x_image P_ ((struct frame *, XImagePtr, Pixmap, int, int));
2049 should indicate the bit depth of the image. */ 1972 should indicate the bit depth of the image. */
2050 1973
2051static int 1974static int
2052x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) 1975x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
2053 struct frame *f; 1976 XImagePtr *ximg, Pixmap *pixmap)
2054 int width, height, depth;
2055 XImagePtr *ximg;
2056 Pixmap *pixmap;
2057{ 1977{
2058#ifdef HAVE_X_WINDOWS 1978#ifdef HAVE_X_WINDOWS
2059 Display *display = FRAME_X_DISPLAY (f); 1979 Display *display = FRAME_X_DISPLAY (f);
@@ -2125,8 +2045,8 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap)
2125 return 0; 2045 return 0;
2126 } 2046 }
2127 2047
2128 header = &((*ximg)->info.bmiHeader); 2048 header = &(*ximg)->info.bmiHeader;
2129 bzero (&((*ximg)->info), sizeof (BITMAPINFO)); 2049 memset (&(*ximg)->info, 0, sizeof (BITMAPINFO));
2130 header->biSize = sizeof (*header); 2050 header->biSize = sizeof (*header);
2131 header->biWidth = width; 2051 header->biWidth = width;
2132 header->biHeight = -height; /* negative indicates a top-down bitmap. */ 2052 header->biHeight = -height; /* negative indicates a top-down bitmap. */
@@ -2176,7 +2096,7 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap)
2176#endif /* HAVE_NTGUI */ 2096#endif /* HAVE_NTGUI */
2177 2097
2178#ifdef HAVE_NS 2098#ifdef HAVE_NS
2179 *pixmap = ns_image_for_XPM(width, height, depth); 2099 *pixmap = ns_image_for_XPM (width, height, depth);
2180 if (*pixmap == 0) 2100 if (*pixmap == 0)
2181 { 2101 {
2182 *ximg = NULL; 2102 *ximg = NULL;
@@ -2192,8 +2112,7 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap)
2192/* Destroy XImage XIMG. Free XIMG->data. */ 2112/* Destroy XImage XIMG. Free XIMG->data. */
2193 2113
2194static void 2114static void
2195x_destroy_x_image (ximg) 2115x_destroy_x_image (XImagePtr ximg)
2196 XImagePtr ximg;
2197{ 2116{
2198 xassert (interrupt_input_blocked); 2117 xassert (interrupt_input_blocked);
2199 if (ximg) 2118 if (ximg)
@@ -2209,7 +2128,7 @@ x_destroy_x_image (ximg)
2209 xfree (ximg); 2128 xfree (ximg);
2210#endif /* HAVE_NTGUI */ 2129#endif /* HAVE_NTGUI */
2211#ifdef HAVE_NS 2130#ifdef HAVE_NS
2212 ns_release_object(ximg); 2131 ns_release_object (ximg);
2213#endif /* HAVE_NS */ 2132#endif /* HAVE_NS */
2214 } 2133 }
2215} 2134}
@@ -2219,11 +2138,7 @@ x_destroy_x_image (ximg)
2219 are width and height of both the image and pixmap. */ 2138 are width and height of both the image and pixmap. */
2220 2139
2221static void 2140static void
2222x_put_x_image (f, ximg, pixmap, width, height) 2141x_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap, int width, int height)
2223 struct frame *f;
2224 XImagePtr ximg;
2225 Pixmap pixmap;
2226 int width, height;
2227{ 2142{
2228#ifdef HAVE_X_WINDOWS 2143#ifdef HAVE_X_WINDOWS
2229 GC gc; 2144 GC gc;
@@ -2244,7 +2159,7 @@ x_put_x_image (f, ximg, pixmap, width, height)
2244 2159
2245#ifdef HAVE_NS 2160#ifdef HAVE_NS
2246 xassert (ximg == pixmap); 2161 xassert (ximg == pixmap);
2247 ns_retain_object(ximg); 2162 ns_retain_object (ximg);
2248#endif 2163#endif
2249} 2164}
2250 2165
@@ -2253,7 +2168,7 @@ x_put_x_image (f, ximg, pixmap, width, height)
2253 File Handling 2168 File Handling
2254***********************************************************************/ 2169***********************************************************************/
2255 2170
2256static unsigned char *slurp_file P_ ((char *, int *)); 2171static unsigned char *slurp_file (char *, int *);
2257 2172
2258 2173
2259/* Find image file FILE. Look in data-directory/images, then 2174/* Find image file FILE. Look in data-directory/images, then
@@ -2261,8 +2176,7 @@ static unsigned char *slurp_file P_ ((char *, int *));
2261 found, or nil if not found. */ 2176 found, or nil if not found. */
2262 2177
2263Lisp_Object 2178Lisp_Object
2264x_find_image_file (file) 2179x_find_image_file (Lisp_Object file)
2265 Lisp_Object file;
2266{ 2180{
2267 Lisp_Object file_found, search_path; 2181 Lisp_Object file_found, search_path;
2268 struct gcpro gcpro1, gcpro2; 2182 struct gcpro gcpro1, gcpro2;
@@ -2297,9 +2211,7 @@ x_find_image_file (file)
2297 occurred. *SIZE is set to the size of the file. */ 2211 occurred. *SIZE is set to the size of the file. */
2298 2212
2299static unsigned char * 2213static unsigned char *
2300slurp_file (file, size) 2214slurp_file (char *file, int *size)
2301 char *file;
2302 int *size;
2303{ 2215{
2304 FILE *fp = NULL; 2216 FILE *fp = NULL;
2305 unsigned char *buf = NULL; 2217 unsigned char *buf = NULL;
@@ -2333,15 +2245,15 @@ slurp_file (file, size)
2333 XBM images 2245 XBM images
2334***********************************************************************/ 2246***********************************************************************/
2335 2247
2336static int xbm_scan P_ ((unsigned char **, unsigned char *, char *, int *)); 2248static int xbm_scan (unsigned char **, unsigned char *, char *, int *);
2337static int xbm_load P_ ((struct frame *f, struct image *img)); 2249static int xbm_load (struct frame *f, struct image *img);
2338static int xbm_load_image P_ ((struct frame *f, struct image *img, 2250static int xbm_load_image (struct frame *f, struct image *img,
2339 unsigned char *, unsigned char *)); 2251 unsigned char *, unsigned char *);
2340static int xbm_image_p P_ ((Lisp_Object object)); 2252static int xbm_image_p (Lisp_Object object);
2341static int xbm_read_bitmap_data P_ ((struct frame *f, 2253static int xbm_read_bitmap_data (struct frame *f,
2342 unsigned char *, unsigned char *, 2254 unsigned char *, unsigned char *,
2343 int *, int *, unsigned char **, int)); 2255 int *, int *, unsigned char **, int);
2344static int xbm_file_p P_ ((Lisp_Object)); 2256static int xbm_file_p (Lisp_Object);
2345 2257
2346 2258
2347/* Indices of image specification fields in xbm_format, below. */ 2259/* Indices of image specification fields in xbm_format, below. */
@@ -2434,12 +2346,11 @@ enum xbm_token
2434 displayed is used. */ 2346 displayed is used. */
2435 2347
2436static int 2348static int
2437xbm_image_p (object) 2349xbm_image_p (Lisp_Object object)
2438 Lisp_Object object;
2439{ 2350{
2440 struct image_keyword kw[XBM_LAST]; 2351 struct image_keyword kw[XBM_LAST];
2441 2352
2442 bcopy (xbm_format, kw, sizeof kw); 2353 memcpy (kw, xbm_format, sizeof kw);
2443 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm)) 2354 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))
2444 return 0; 2355 return 0;
2445 2356
@@ -2528,10 +2439,7 @@ xbm_image_p (object)
2528 scanning a number, store its value in *IVAL. */ 2439 scanning a number, store its value in *IVAL. */
2529 2440
2530static int 2441static int
2531xbm_scan (s, end, sval, ival) 2442xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
2532 unsigned char **s, *end;
2533 char *sval;
2534 int *ival;
2535{ 2443{
2536 unsigned int c; 2444 unsigned int c;
2537 2445
@@ -2632,7 +2540,7 @@ w32_create_pixmap_from_bitmap_data (int width, int height, char *data)
2632 w1 = (width + 7) / 8; /* nb of 8bits elt in X bitmap */ 2540 w1 = (width + 7) / 8; /* nb of 8bits elt in X bitmap */
2633 w2 = ((width + 15) / 16) * 2; /* nb of 16bits elt in W32 bitmap */ 2541 w2 = ((width + 15) / 16) * 2; /* nb of 16bits elt in W32 bitmap */
2634 bits = (unsigned char *) alloca (height * w2); 2542 bits = (unsigned char *) alloca (height * w2);
2635 bzero (bits, height * w2); 2543 memset (bits, 0, height * w2);
2636 for (i = 0; i < height; i++) 2544 for (i = 0; i < height; i++)
2637 { 2545 {
2638 p = bits + i*w2; 2546 p = bits + i*w2;
@@ -2650,10 +2558,8 @@ w32_create_pixmap_from_bitmap_data (int width, int height, char *data)
2650} 2558}
2651 2559
2652static void 2560static void
2653convert_mono_to_color_image (f, img, foreground, background) 2561convert_mono_to_color_image (struct frame *f, struct image *img,
2654 struct frame *f; 2562 COLORREF foreground, COLORREF background)
2655 struct image *img;
2656 COLORREF foreground, background;
2657{ 2563{
2658 HDC hdc, old_img_dc, new_img_dc; 2564 HDC hdc, old_img_dc, new_img_dc;
2659 HGDIOBJ old_prev, new_prev; 2565 HGDIOBJ old_prev, new_prev;
@@ -2695,12 +2601,9 @@ convert_mono_to_color_image (f, img, foreground, background)
2695 2601
2696 2602
2697static void 2603static void
2698Create_Pixmap_From_Bitmap_Data (f, img, data, fg, bg, non_default_colors) 2604Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data,
2699 struct frame *f; 2605 RGB_PIXEL_COLOR fg, RGB_PIXEL_COLOR bg,
2700 struct image *img; 2606 int non_default_colors)
2701 char *data;
2702 RGB_PIXEL_COLOR fg, bg;
2703 int non_default_colors;
2704{ 2607{
2705#ifdef HAVE_NTGUI 2608#ifdef HAVE_NTGUI
2706 img->pixmap 2609 img->pixmap
@@ -2711,7 +2614,7 @@ Create_Pixmap_From_Bitmap_Data (f, img, data, fg, bg, non_default_colors)
2711 convert_mono_to_color_image (f, img, fg, bg); 2614 convert_mono_to_color_image (f, img, fg, bg);
2712 2615
2713#elif defined (HAVE_NS) 2616#elif defined (HAVE_NS)
2714 img->pixmap = ns_image_from_XBM(data, img->width, img->height); 2617 img->pixmap = ns_image_from_XBM (data, img->width, img->height);
2715 2618
2716#else 2619#else
2717 img->pixmap 2620 img->pixmap
@@ -2736,12 +2639,9 @@ Create_Pixmap_From_Bitmap_Data (f, img, data, fg, bg, non_default_colors)
2736 invalid (the bitmap remains unread). */ 2639 invalid (the bitmap remains unread). */
2737 2640
2738static int 2641static int
2739xbm_read_bitmap_data (f, contents, end, width, height, data, inhibit_image_error) 2642xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *end,
2740 struct frame *f; 2643 int *width, int *height, unsigned char **data,
2741 unsigned char *contents, *end; 2644 int inhibit_image_error)
2742 int *width, *height;
2743 unsigned char **data;
2744 int inhibit_image_error;
2745{ 2645{
2746 unsigned char *s = contents; 2646 unsigned char *s = contents;
2747 char buffer[BUFSIZ]; 2647 char buffer[BUFSIZ];
@@ -2890,10 +2790,8 @@ xbm_read_bitmap_data (f, contents, end, width, height, data, inhibit_image_error
2890 successful. */ 2790 successful. */
2891 2791
2892static int 2792static int
2893xbm_load_image (f, img, contents, end) 2793xbm_load_image (struct frame *f, struct image *img, unsigned char *contents,
2894 struct frame *f; 2794 unsigned char *end)
2895 struct image *img;
2896 unsigned char *contents, *end;
2897{ 2795{
2898 int rc; 2796 int rc;
2899 unsigned char *data; 2797 unsigned char *data;
@@ -2949,8 +2847,7 @@ xbm_load_image (f, img, contents, end)
2949/* Value is non-zero if DATA looks like an in-memory XBM file. */ 2847/* Value is non-zero if DATA looks like an in-memory XBM file. */
2950 2848
2951static int 2849static int
2952xbm_file_p (data) 2850xbm_file_p (Lisp_Object data)
2953 Lisp_Object data;
2954{ 2851{
2955 int w, h; 2852 int w, h;
2956 return (STRINGP (data) 2853 return (STRINGP (data)
@@ -2964,9 +2861,7 @@ xbm_file_p (data)
2964 non-zero if successful. */ 2861 non-zero if successful. */
2965 2862
2966static int 2863static int
2967xbm_load (f, img) 2864xbm_load (struct frame *f, struct image *img)
2968 struct frame *f;
2969 struct image *img;
2970{ 2865{
2971 int success_p = 0; 2866 int success_p = 0;
2972 Lisp_Object file_name; 2867 Lisp_Object file_name;
@@ -3018,7 +2913,7 @@ xbm_load (f, img)
3018 in_memory_file_p = xbm_file_p (data); 2913 in_memory_file_p = xbm_file_p (data);
3019 2914
3020 /* Parse the image specification. */ 2915 /* Parse the image specification. */
3021 bcopy (xbm_format, fmt, sizeof fmt); 2916 memcpy (fmt, xbm_format, sizeof fmt);
3022 parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm); 2917 parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm);
3023 xassert (parsed_p); 2918 xassert (parsed_p);
3024 2919
@@ -3064,9 +2959,9 @@ xbm_load (f, img)
3064 { 2959 {
3065 Lisp_Object line = XVECTOR (data)->contents[i]; 2960 Lisp_Object line = XVECTOR (data)->contents[i];
3066 if (STRINGP (line)) 2961 if (STRINGP (line))
3067 bcopy (SDATA (line), p, nbytes); 2962 memcpy (p, SDATA (line), nbytes);
3068 else 2963 else
3069 bcopy (XBOOL_VECTOR (line)->data, p, nbytes); 2964 memcpy (p, XBOOL_VECTOR (line)->data, nbytes);
3070 } 2965 }
3071 } 2966 }
3072 else if (STRINGP (data)) 2967 else if (STRINGP (data))
@@ -3082,7 +2977,7 @@ xbm_load (f, img)
3082 invertedBits = bits; 2977 invertedBits = bits;
3083 nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR 2978 nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR
3084 * img->height; 2979 * img->height;
3085 bits = (char *) alloca(nbytes); 2980 bits = (char *) alloca (nbytes);
3086 for (i = 0; i < nbytes; i++) 2981 for (i = 0; i < nbytes; i++)
3087 bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]); 2982 bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]);
3088 } 2983 }
@@ -3114,9 +3009,9 @@ xbm_load (f, img)
3114 3009
3115#if defined (HAVE_XPM) || defined (HAVE_NS) 3010#if defined (HAVE_XPM) || defined (HAVE_NS)
3116 3011
3117static int xpm_image_p P_ ((Lisp_Object object)); 3012static int xpm_image_p (Lisp_Object object);
3118static int xpm_load P_ ((struct frame *f, struct image *img)); 3013static int xpm_load (struct frame *f, struct image *img);
3119static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); 3014static int xpm_valid_color_symbols_p (Lisp_Object);
3120 3015
3121#endif /* HAVE_XPM || HAVE_NS */ 3016#endif /* HAVE_XPM || HAVE_NS */
3122 3017
@@ -3207,12 +3102,12 @@ static struct image_type xpm_type =
3207 3102
3208#ifdef ALLOC_XPM_COLORS 3103#ifdef ALLOC_XPM_COLORS
3209 3104
3210static void xpm_init_color_cache P_ ((struct frame *, XpmAttributes *)); 3105static void xpm_init_color_cache (struct frame *, XpmAttributes *);
3211static void xpm_free_color_cache P_ ((void)); 3106static void xpm_free_color_cache (void);
3212static int xpm_lookup_color P_ ((struct frame *, char *, XColor *)); 3107static int xpm_lookup_color (struct frame *, char *, XColor *);
3213static int xpm_color_bucket P_ ((char *)); 3108static int xpm_color_bucket (char *);
3214static struct xpm_cached_color *xpm_cache_color P_ ((struct frame *, char *, 3109static struct xpm_cached_color *xpm_cache_color (struct frame *, char *,
3215 XColor *, int)); 3110 XColor *, int);
3216 3111
3217/* An entry in a hash table used to cache color definitions of named 3112/* An entry in a hash table used to cache color definitions of named
3218 colors. This cache is necessary to speed up XPM image loading in 3113 colors. This cache is necessary to speed up XPM image loading in
@@ -3240,9 +3135,7 @@ struct xpm_cached_color **xpm_color_cache;
3240/* Initialize the color cache. */ 3135/* Initialize the color cache. */
3241 3136
3242static void 3137static void
3243xpm_init_color_cache (f, attrs) 3138xpm_init_color_cache (struct frame *f, XpmAttributes *attrs)
3244 struct frame *f;
3245 XpmAttributes *attrs;
3246{ 3139{
3247 size_t nbytes = XPM_COLOR_CACHE_BUCKETS * sizeof *xpm_color_cache; 3140 size_t nbytes = XPM_COLOR_CACHE_BUCKETS * sizeof *xpm_color_cache;
3248 xpm_color_cache = (struct xpm_cached_color **) xmalloc (nbytes); 3141 xpm_color_cache = (struct xpm_cached_color **) xmalloc (nbytes);
@@ -3268,7 +3161,7 @@ xpm_init_color_cache (f, attrs)
3268/* Free the color cache. */ 3161/* Free the color cache. */
3269 3162
3270static void 3163static void
3271xpm_free_color_cache () 3164xpm_free_color_cache (void)
3272{ 3165{
3273 struct xpm_cached_color *p, *next; 3166 struct xpm_cached_color *p, *next;
3274 int i; 3167 int i;
@@ -3289,8 +3182,7 @@ xpm_free_color_cache ()
3289 cache. */ 3182 cache. */
3290 3183
3291static int 3184static int
3292xpm_color_bucket (color_name) 3185xpm_color_bucket (char *color_name)
3293 char *color_name;
3294{ 3186{
3295 unsigned h = 0; 3187 unsigned h = 0;
3296 char *s; 3188 char *s;
@@ -3306,11 +3198,7 @@ xpm_color_bucket (color_name)
3306 entry added. */ 3198 entry added. */
3307 3199
3308static struct xpm_cached_color * 3200static struct xpm_cached_color *
3309xpm_cache_color (f, color_name, color, bucket) 3201xpm_cache_color (struct frame *f, char *color_name, XColor *color, int bucket)
3310 struct frame *f;
3311 char *color_name;
3312 XColor *color;
3313 int bucket;
3314{ 3202{
3315 size_t nbytes; 3203 size_t nbytes;
3316 struct xpm_cached_color *p; 3204 struct xpm_cached_color *p;
@@ -3333,10 +3221,7 @@ xpm_cache_color (f, color_name, color, bucket)
3333 allocation failed. */ 3221 allocation failed. */
3334 3222
3335static int 3223static int
3336xpm_lookup_color (f, color_name, color) 3224xpm_lookup_color (struct frame *f, char *color_name, XColor *color)
3337 struct frame *f;
3338 char *color_name;
3339 XColor *color;
3340{ 3225{
3341 struct xpm_cached_color *p; 3226 struct xpm_cached_color *p;
3342 int h = xpm_color_bucket (color_name); 3227 int h = xpm_color_bucket (color_name);
@@ -3358,7 +3243,7 @@ xpm_lookup_color (f, color_name, color)
3358 with transparency, and it's useful. */ 3243 with transparency, and it's useful. */
3359 else if (strcmp ("opaque", color_name) == 0) 3244 else if (strcmp ("opaque", color_name) == 0)
3360 { 3245 {
3361 bzero (color, sizeof (XColor)); /* Is this necessary/correct? */ 3246 memset (color, 0, sizeof (XColor)); /* Is this necessary/correct? */
3362 color->pixel = FRAME_FOREGROUND_PIXEL (f); 3247 color->pixel = FRAME_FOREGROUND_PIXEL (f);
3363 p = xpm_cache_color (f, color_name, color, h); 3248 p = xpm_cache_color (f, color_name, color, h);
3364 } 3249 }
@@ -3373,12 +3258,8 @@ xpm_lookup_color (f, color_name, color)
3373 if successful. */ 3258 if successful. */
3374 3259
3375static int 3260static int
3376xpm_alloc_color (dpy, cmap, color_name, color, closure) 3261xpm_alloc_color (Display *dpy, Colormap cmap, char *color_name, XColor *color,
3377 Display *dpy; 3262 void *closure)
3378 Colormap cmap;
3379 char *color_name;
3380 XColor *color;
3381 void *closure;
3382{ 3263{
3383 return xpm_lookup_color ((struct frame *) closure, color_name, color); 3264 return xpm_lookup_color ((struct frame *) closure, color_name, color);
3384} 3265}
@@ -3389,12 +3270,7 @@ xpm_alloc_color (dpy, cmap, color_name, color, closure)
3389 non-zero if successful. */ 3270 non-zero if successful. */
3390 3271
3391static int 3272static int
3392xpm_free_colors (dpy, cmap, pixels, npixels, closure) 3273xpm_free_colors (Display *dpy, Colormap cmap, Pixel *pixels, int npixels, void *closure)
3393 Display *dpy;
3394 Colormap cmap;
3395 Pixel *pixels;
3396 int npixels;
3397 void *closure;
3398{ 3274{
3399 return 1; 3275 return 1;
3400} 3276}
@@ -3434,8 +3310,7 @@ init_xpm_functions (Lisp_Object libraries)
3434 cdr are strings. */ 3310 cdr are strings. */
3435 3311
3436static int 3312static int
3437xpm_valid_color_symbols_p (color_symbols) 3313xpm_valid_color_symbols_p (Lisp_Object color_symbols)
3438 Lisp_Object color_symbols;
3439{ 3314{
3440 while (CONSP (color_symbols)) 3315 while (CONSP (color_symbols))
3441 { 3316 {
@@ -3454,11 +3329,10 @@ xpm_valid_color_symbols_p (color_symbols)
3454/* Value is non-zero if OBJECT is a valid XPM image specification. */ 3329/* Value is non-zero if OBJECT is a valid XPM image specification. */
3455 3330
3456static int 3331static int
3457xpm_image_p (object) 3332xpm_image_p (Lisp_Object object)
3458 Lisp_Object object;
3459{ 3333{
3460 struct image_keyword fmt[XPM_LAST]; 3334 struct image_keyword fmt[XPM_LAST];
3461 bcopy (xpm_format, fmt, sizeof fmt); 3335 memcpy (fmt, xpm_format, sizeof fmt);
3462 return (parse_image_spec (object, fmt, XPM_LAST, Qxpm) 3336 return (parse_image_spec (object, fmt, XPM_LAST, Qxpm)
3463 /* Either `:file' or `:data' must be present. */ 3337 /* Either `:file' or `:data' must be present. */
3464 && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1 3338 && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1
@@ -3472,16 +3346,14 @@ xpm_image_p (object)
3472 3346
3473#if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) 3347#if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)
3474int 3348int
3475x_create_bitmap_from_xpm_data (f, bits) 3349x_create_bitmap_from_xpm_data (struct frame *f, char **bits)
3476 struct frame *f;
3477 char **bits;
3478{ 3350{
3479 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 3351 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
3480 int id, rc; 3352 int id, rc;
3481 XpmAttributes attrs; 3353 XpmAttributes attrs;
3482 Pixmap bitmap, mask; 3354 Pixmap bitmap, mask;
3483 3355
3484 bzero (&attrs, sizeof attrs); 3356 memset (&attrs, 0, sizeof attrs);
3485 3357
3486 attrs.visual = FRAME_X_VISUAL (f); 3358 attrs.visual = FRAME_X_VISUAL (f);
3487 attrs.colormap = FRAME_X_COLORMAP (f); 3359 attrs.colormap = FRAME_X_COLORMAP (f);
@@ -3517,9 +3389,7 @@ x_create_bitmap_from_xpm_data (f, bits)
3517#ifdef HAVE_XPM 3389#ifdef HAVE_XPM
3518 3390
3519static int 3391static int
3520xpm_load (f, img) 3392xpm_load (struct frame *f, struct image *img)
3521 struct frame *f;
3522 struct image *img;
3523{ 3393{
3524 int rc; 3394 int rc;
3525 XpmAttributes attrs; 3395 XpmAttributes attrs;
@@ -3531,7 +3401,7 @@ xpm_load (f, img)
3531 3401
3532 /* Configure the XPM lib. Use the visual of frame F. Allocate 3402 /* Configure the XPM lib. Use the visual of frame F. Allocate
3533 close colors. Return colors allocated. */ 3403 close colors. Return colors allocated. */
3534 bzero (&attrs, sizeof attrs); 3404 memset (&attrs, 0, sizeof attrs);
3535 3405
3536#ifndef HAVE_NTGUI 3406#ifndef HAVE_NTGUI
3537 attrs.visual = FRAME_X_VISUAL (f); 3407 attrs.visual = FRAME_X_VISUAL (f);
@@ -3578,7 +3448,7 @@ xpm_load (f, img)
3578 /* Allocate an XpmColorSymbol array. */ 3448 /* Allocate an XpmColorSymbol array. */
3579 size = attrs.numsymbols * sizeof *xpm_syms; 3449 size = attrs.numsymbols * sizeof *xpm_syms;
3580 xpm_syms = (XpmColorSymbol *) alloca (size); 3450 xpm_syms = (XpmColorSymbol *) alloca (size);
3581 bzero (xpm_syms, size); 3451 memset (xpm_syms, 0, size);
3582 attrs.colorsymbols = xpm_syms; 3452 attrs.colorsymbols = xpm_syms;
3583 3453
3584 /* Fill the color symbol array. */ 3454 /* Fill the color symbol array. */
@@ -3752,25 +3622,25 @@ xpm_load (f, img)
3752/* XPM support functions for NS where libxpm is not available. 3622/* XPM support functions for NS where libxpm is not available.
3753 Only XPM version 3 (without any extensions) is supported. */ 3623 Only XPM version 3 (without any extensions) is supported. */
3754 3624
3755static int xpm_scan P_ ((const unsigned char **, const unsigned char *, 3625static int xpm_scan (const unsigned char **, const unsigned char *,
3756 const unsigned char **, int *)); 3626 const unsigned char **, int *);
3757static Lisp_Object xpm_make_color_table_v 3627static Lisp_Object xpm_make_color_table_v
3758P_ ((void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object), 3628 (void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object),
3759 Lisp_Object (**) (Lisp_Object, const unsigned char *, int))); 3629 Lisp_Object (**) (Lisp_Object, const unsigned char *, int));
3760static void xpm_put_color_table_v P_ ((Lisp_Object, const unsigned char *, 3630static void xpm_put_color_table_v (Lisp_Object, const unsigned char *,
3761 int, Lisp_Object)); 3631 int, Lisp_Object);
3762static Lisp_Object xpm_get_color_table_v P_ ((Lisp_Object, 3632static Lisp_Object xpm_get_color_table_v (Lisp_Object,
3763 const unsigned char *, int)); 3633 const unsigned char *, int);
3764static Lisp_Object xpm_make_color_table_h 3634static Lisp_Object xpm_make_color_table_h
3765P_ ((void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object), 3635 (void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object),
3766 Lisp_Object (**) (Lisp_Object, const unsigned char *, int))); 3636 Lisp_Object (**) (Lisp_Object, const unsigned char *, int));
3767static void xpm_put_color_table_h P_ ((Lisp_Object, const unsigned char *, 3637static void xpm_put_color_table_h (Lisp_Object, const unsigned char *,
3768 int, Lisp_Object)); 3638 int, Lisp_Object);
3769static Lisp_Object xpm_get_color_table_h P_ ((Lisp_Object, 3639static Lisp_Object xpm_get_color_table_h (Lisp_Object,
3770 const unsigned char *, int)); 3640 const unsigned char *, int);
3771static int xpm_str_to_color_key P_ ((const char *)); 3641static int xpm_str_to_color_key (const char *);
3772static int xpm_load_image P_ ((struct frame *, struct image *, 3642static int xpm_load_image (struct frame *, struct image *,
3773 const unsigned char *, const unsigned char *)); 3643 const unsigned char *, const unsigned char *);
3774 3644
3775/* Tokens returned from xpm_scan. */ 3645/* Tokens returned from xpm_scan. */
3776 3646
@@ -3789,9 +3659,10 @@ enum xpm_token
3789 length of the corresponding token, respectively. */ 3659 length of the corresponding token, respectively. */
3790 3660
3791static int 3661static int
3792xpm_scan (s, end, beg, len) 3662xpm_scan (const unsigned char **s,
3793 const unsigned char **s, *end, **beg; 3663 const unsigned char *end,
3794 int *len; 3664 const unsigned char **beg,
3665 int *len)
3795{ 3666{
3796 int c; 3667 int c;
3797 3668
@@ -3855,9 +3726,13 @@ xpm_scan (s, end, beg, len)
3855 hash table is used. */ 3726 hash table is used. */
3856 3727
3857static Lisp_Object 3728static Lisp_Object
3858xpm_make_color_table_v (put_func, get_func) 3729xpm_make_color_table_v (void (**put_func) (Lisp_Object,
3859 void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object); 3730 const unsigned char *,
3860 Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int); 3731 int,
3732 Lisp_Object),
3733 Lisp_Object (**get_func) (Lisp_Object,
3734 const unsigned char *,
3735 int))
3861{ 3736{
3862 *put_func = xpm_put_color_table_v; 3737 *put_func = xpm_put_color_table_v;
3863 *get_func = xpm_get_color_table_v; 3738 *get_func = xpm_get_color_table_v;
@@ -3865,28 +3740,30 @@ xpm_make_color_table_v (put_func, get_func)
3865} 3740}
3866 3741
3867static void 3742static void
3868xpm_put_color_table_v (color_table, chars_start, chars_len, color) 3743xpm_put_color_table_v (Lisp_Object color_table,
3869 Lisp_Object color_table; 3744 const unsigned char *chars_start,
3870 const unsigned char *chars_start; 3745 int chars_len,
3871 int chars_len; 3746 Lisp_Object color)
3872 Lisp_Object color;
3873{ 3747{
3874 XVECTOR (color_table)->contents[*chars_start] = color; 3748 XVECTOR (color_table)->contents[*chars_start] = color;
3875} 3749}
3876 3750
3877static Lisp_Object 3751static Lisp_Object
3878xpm_get_color_table_v (color_table, chars_start, chars_len) 3752xpm_get_color_table_v (Lisp_Object color_table,
3879 Lisp_Object color_table; 3753 const unsigned char *chars_start,
3880 const unsigned char *chars_start; 3754 int chars_len)
3881 int chars_len;
3882{ 3755{
3883 return XVECTOR (color_table)->contents[*chars_start]; 3756 return XVECTOR (color_table)->contents[*chars_start];
3884} 3757}
3885 3758
3886static Lisp_Object 3759static Lisp_Object
3887xpm_make_color_table_h (put_func, get_func) 3760xpm_make_color_table_h (void (**put_func) (Lisp_Object,
3888 void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object); 3761 const unsigned char *,
3889 Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int); 3762 int,
3763 Lisp_Object),
3764 Lisp_Object (**get_func) (Lisp_Object,
3765 const unsigned char *,
3766 int))
3890{ 3767{
3891 *put_func = xpm_put_color_table_h; 3768 *put_func = xpm_put_color_table_h;
3892 *get_func = xpm_get_color_table_h; 3769 *get_func = xpm_get_color_table_h;
@@ -3897,11 +3774,10 @@ xpm_make_color_table_h (put_func, get_func)
3897} 3774}
3898 3775
3899static void 3776static void
3900xpm_put_color_table_h (color_table, chars_start, chars_len, color) 3777xpm_put_color_table_h (Lisp_Object color_table,
3901 Lisp_Object color_table; 3778 const unsigned char *chars_start,
3902 const unsigned char *chars_start; 3779 int chars_len,
3903 int chars_len; 3780 Lisp_Object color)
3904 Lisp_Object color;
3905{ 3781{
3906 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); 3782 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
3907 unsigned hash_code; 3783 unsigned hash_code;
@@ -3912,10 +3788,9 @@ xpm_put_color_table_h (color_table, chars_start, chars_len, color)
3912} 3788}
3913 3789
3914static Lisp_Object 3790static Lisp_Object
3915xpm_get_color_table_h (color_table, chars_start, chars_len) 3791xpm_get_color_table_h (Lisp_Object color_table,
3916 Lisp_Object color_table; 3792 const unsigned char *chars_start,
3917 const unsigned char *chars_start; 3793 int chars_len)
3918 int chars_len;
3919{ 3794{
3920 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); 3795 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
3921 int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len), 3796 int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len),
@@ -3935,8 +3810,7 @@ enum xpm_color_key {
3935static const char xpm_color_key_strings[][4] = {"s", "m", "g4", "g", "c"}; 3810static const char xpm_color_key_strings[][4] = {"s", "m", "g4", "g", "c"};
3936 3811
3937static int 3812static int
3938xpm_str_to_color_key (s) 3813xpm_str_to_color_key (const char *s)
3939 const char *s;
3940{ 3814{
3941 int i; 3815 int i;
3942 3816
@@ -3949,10 +3823,10 @@ xpm_str_to_color_key (s)
3949} 3823}
3950 3824
3951static int 3825static int
3952xpm_load_image (f, img, contents, end) 3826xpm_load_image (struct frame *f,
3953 struct frame *f; 3827 struct image *img,
3954 struct image *img; 3828 const unsigned char *contents,
3955 const unsigned char *contents, *end; 3829 const unsigned char *end)
3956{ 3830{
3957 const unsigned char *s = contents, *beg, *str; 3831 const unsigned char *s = contents, *beg, *str;
3958 unsigned char buffer[BUFSIZ]; 3832 unsigned char buffer[BUFSIZ];
@@ -3984,7 +3858,7 @@ xpm_load_image (f, img, contents, end)
3984 if (!(end - s >= 9 && memcmp (s, "/* XPM */", 9) == 0)) 3858 if (!(end - s >= 9 && memcmp (s, "/* XPM */", 9) == 0))
3985 goto failure; 3859 goto failure;
3986 s += 9; 3860 s += 9;
3987 match(); 3861 match ();
3988 expect_ident ("static"); 3862 expect_ident ("static");
3989 expect_ident ("char"); 3863 expect_ident ("char");
3990 expect ('*'); 3864 expect ('*');
@@ -4134,8 +4008,8 @@ xpm_load_image (f, img, contents, end)
4134 (!EQ (color_val, Qt) ? PIX_MASK_DRAW 4008 (!EQ (color_val, Qt) ? PIX_MASK_DRAW
4135 : (have_mask = 1, PIX_MASK_RETAIN))); 4009 : (have_mask = 1, PIX_MASK_RETAIN)));
4136#else 4010#else
4137 if (EQ(color_val, Qt)) 4011 if (EQ (color_val, Qt))
4138 ns_set_alpha(ximg, x, y, 0); 4012 ns_set_alpha (ximg, x, y, 0);
4139#endif 4013#endif
4140 } 4014 }
4141 if (y + 1 < height) 4015 if (y + 1 < height)
@@ -4184,9 +4058,8 @@ xpm_load_image (f, img, contents, end)
4184} 4058}
4185 4059
4186static int 4060static int
4187xpm_load (f, img) 4061xpm_load (struct frame *f,
4188 struct frame *f; 4062 struct image *img)
4189 struct image *img;
4190{ 4063{
4191 int success_p = 0; 4064 int success_p = 0;
4192 Lisp_Object file_name; 4065 Lisp_Object file_name;
@@ -4273,11 +4146,11 @@ int ct_colors_allocated;
4273/* Initialize the color table. */ 4146/* Initialize the color table. */
4274 4147
4275static void 4148static void
4276init_color_table () 4149init_color_table (void)
4277{ 4150{
4278 int size = CT_SIZE * sizeof (*ct_table); 4151 int size = CT_SIZE * sizeof (*ct_table);
4279 ct_table = (struct ct_color **) xmalloc (size); 4152 ct_table = (struct ct_color **) xmalloc (size);
4280 bzero (ct_table, size); 4153 memset (ct_table, 0, size);
4281 ct_colors_allocated = 0; 4154 ct_colors_allocated = 0;
4282} 4155}
4283 4156
@@ -4285,7 +4158,7 @@ init_color_table ()
4285/* Free memory associated with the color table. */ 4158/* Free memory associated with the color table. */
4286 4159
4287static void 4160static void
4288free_color_table () 4161free_color_table (void)
4289{ 4162{
4290 int i; 4163 int i;
4291 struct ct_color *p, *next; 4164 struct ct_color *p, *next;
@@ -4308,9 +4181,7 @@ free_color_table ()
4308 G, B, and make an entry in the color table. */ 4181 G, B, and make an entry in the color table. */
4309 4182
4310static unsigned long 4183static unsigned long
4311lookup_rgb_color (f, r, g, b) 4184lookup_rgb_color (struct frame *f, int r, int g, int b)
4312 struct frame *f;
4313 int r, g, b;
4314{ 4185{
4315 unsigned hash = CT_HASH_RGB (r, g, b); 4186 unsigned hash = CT_HASH_RGB (r, g, b);
4316 int i = hash % CT_SIZE; 4187 int i = hash % CT_SIZE;
@@ -4405,9 +4276,7 @@ lookup_rgb_color (f, r, g, b)
4405 table. If not already present, allocate it. Value is PIXEL. */ 4276 table. If not already present, allocate it. Value is PIXEL. */
4406 4277
4407static unsigned long 4278static unsigned long
4408lookup_pixel_color (f, pixel) 4279lookup_pixel_color (struct frame *f, unsigned long pixel)
4409 struct frame *f;
4410 unsigned long pixel;
4411{ 4280{
4412 int i = pixel % CT_SIZE; 4281 int i = pixel % CT_SIZE;
4413 struct ct_color *p; 4282 struct ct_color *p;
@@ -4459,8 +4328,7 @@ lookup_pixel_color (f, pixel)
4459 allocated via xmalloc. Set *N to the number of colors. */ 4328 allocated via xmalloc. Set *N to the number of colors. */
4460 4329
4461static unsigned long * 4330static unsigned long *
4462colors_in_color_table (n) 4331colors_in_color_table (int *n)
4463 int *n;
4464{ 4332{
4465 int i, j; 4333 int i, j;
4466 struct ct_color *p; 4334 struct ct_color *p;
@@ -4488,9 +4356,7 @@ colors_in_color_table (n)
4488#else /* COLOR_TABLE_SUPPORT */ 4356#else /* COLOR_TABLE_SUPPORT */
4489 4357
4490static unsigned long 4358static unsigned long
4491lookup_rgb_color (f, r, g, b) 4359lookup_rgb_color (struct frame *f, int r, int g, int b)
4492 struct frame *f;
4493 int r, g, b;
4494{ 4360{
4495 unsigned long pixel; 4361 unsigned long pixel;
4496 4362
@@ -4505,7 +4371,7 @@ lookup_rgb_color (f, r, g, b)
4505} 4371}
4506 4372
4507static void 4373static void
4508init_color_table () 4374init_color_table (void)
4509{ 4375{
4510} 4376}
4511#endif /* COLOR_TABLE_SUPPORT */ 4377#endif /* COLOR_TABLE_SUPPORT */
@@ -4515,9 +4381,9 @@ init_color_table ()
4515 Algorithms 4381 Algorithms
4516***********************************************************************/ 4382***********************************************************************/
4517 4383
4518static XColor *x_to_xcolors P_ ((struct frame *, struct image *, int)); 4384static XColor *x_to_xcolors (struct frame *, struct image *, int);
4519static void x_from_xcolors P_ ((struct frame *, struct image *, XColor *)); 4385static void x_from_xcolors (struct frame *, struct image *, XColor *);
4520static void x_detect_edges P_ ((struct frame *, struct image *, int[9], int)); 4386static void x_detect_edges (struct frame *, struct image *, int[9], int);
4521 4387
4522#ifdef HAVE_NTGUI 4388#ifdef HAVE_NTGUI
4523static void XPutPixel (XImagePtr , int, int, COLORREF); 4389static void XPutPixel (XImagePtr , int, int, COLORREF);
@@ -4558,10 +4424,7 @@ static int laplace_matrix[9] = {
4558 allocated with xmalloc; it must be freed by the caller. */ 4424 allocated with xmalloc; it must be freed by the caller. */
4559 4425
4560static XColor * 4426static XColor *
4561x_to_xcolors (f, img, rgb_p) 4427x_to_xcolors (struct frame *f, struct image *img, int rgb_p)
4562 struct frame *f;
4563 struct image *img;
4564 int rgb_p;
4565{ 4428{
4566 int x, y; 4429 int x, y;
4567 XColor *colors, *p; 4430 XColor *colors, *p;
@@ -4626,10 +4489,7 @@ x_to_xcolors (f, img, rgb_p)
4626 stored in ximg->data. */ 4489 stored in ximg->data. */
4627 4490
4628static void 4491static void
4629XPutPixel (ximg, x, y, color) 4492XPutPixel (XImagePtr ximg, int x, int y, COLORREF color)
4630 XImagePtr ximg;
4631 int x, y;
4632 COLORREF color;
4633{ 4493{
4634 int width = ximg->info.bmiHeader.biWidth; 4494 int width = ximg->info.bmiHeader.biWidth;
4635 int height = ximg->info.bmiHeader.biHeight; 4495 int height = ximg->info.bmiHeader.biHeight;
@@ -4674,10 +4534,7 @@ XPutPixel (ximg, x, y, color)
4674 COLORS will be freed; an existing IMG->pixmap will be freed, too. */ 4534 COLORS will be freed; an existing IMG->pixmap will be freed, too. */
4675 4535
4676static void 4536static void
4677x_from_xcolors (f, img, colors) 4537x_from_xcolors (struct frame *f, struct image *img, XColor *colors)
4678 struct frame *f;
4679 struct image *img;
4680 XColor *colors;
4681{ 4538{
4682 int x, y; 4539 int x, y;
4683 XImagePtr oimg = NULL; 4540 XImagePtr oimg = NULL;
@@ -4719,10 +4576,7 @@ x_from_xcolors (f, img, colors)
4719 outgoing image. */ 4576 outgoing image. */
4720 4577
4721static void 4578static void
4722x_detect_edges (f, img, matrix, color_adjust) 4579x_detect_edges (struct frame *f, struct image *img, int *matrix, int color_adjust)
4723 struct frame *f;
4724 struct image *img;
4725 int matrix[9], color_adjust;
4726{ 4580{
4727 XColor *colors = x_to_xcolors (f, img, 1); 4581 XColor *colors = x_to_xcolors (f, img, 1);
4728 XColor *new, *p; 4582 XColor *new, *p;
@@ -4788,9 +4642,7 @@ x_detect_edges (f, img, matrix, color_adjust)
4788 on frame F. */ 4642 on frame F. */
4789 4643
4790static void 4644static void
4791x_emboss (f, img) 4645x_emboss (struct frame *f, struct image *img)
4792 struct frame *f;
4793 struct image *img;
4794{ 4646{
4795 x_detect_edges (f, img, emboss_matrix, 0xffff / 2); 4647 x_detect_edges (f, img, emboss_matrix, 0xffff / 2);
4796} 4648}
@@ -4801,9 +4653,7 @@ x_emboss (f, img)
4801 to draw disabled buttons, for example. */ 4653 to draw disabled buttons, for example. */
4802 4654
4803static void 4655static void
4804x_laplace (f, img) 4656x_laplace (struct frame *f, struct image *img)
4805 struct frame *f;
4806 struct image *img;
4807{ 4657{
4808 x_detect_edges (f, img, laplace_matrix, 45000); 4658 x_detect_edges (f, img, laplace_matrix, 45000);
4809} 4659}
@@ -4821,10 +4671,8 @@ x_laplace (f, img)
4821 number. */ 4671 number. */
4822 4672
4823static void 4673static void
4824x_edge_detection (f, img, matrix, color_adjust) 4674x_edge_detection (struct frame *f, struct image *img, Lisp_Object matrix,
4825 struct frame *f; 4675 Lisp_Object color_adjust)
4826 struct image *img;
4827 Lisp_Object matrix, color_adjust;
4828{ 4676{
4829 int i = 0; 4677 int i = 0;
4830 int trans[9]; 4678 int trans[9];
@@ -4853,9 +4701,7 @@ x_edge_detection (f, img, matrix, color_adjust)
4853/* Transform image IMG on frame F so that it looks disabled. */ 4701/* Transform image IMG on frame F so that it looks disabled. */
4854 4702
4855static void 4703static void
4856x_disable_image (f, img) 4704x_disable_image (struct frame *f, struct image *img)
4857 struct frame *f;
4858 struct image *img;
4859{ 4705{
4860 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 4706 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
4861#ifdef HAVE_NTGUI 4707#ifdef HAVE_NTGUI
@@ -4957,10 +4803,7 @@ x_disable_image (f, img)
4957 heuristically. Value is non-zero if successful. */ 4803 heuristically. Value is non-zero if successful. */
4958 4804
4959static int 4805static int
4960x_build_heuristic_mask (f, img, how) 4806x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
4961 struct frame *f;
4962 struct image *img;
4963 Lisp_Object how;
4964{ 4807{
4965 XImagePtr_or_DC ximg; 4808 XImagePtr_or_DC ximg;
4966#ifndef HAVE_NTGUI 4809#ifndef HAVE_NTGUI
@@ -4998,7 +4841,7 @@ x_build_heuristic_mask (f, img, how)
4998 /* Create the bit array serving as mask. */ 4841 /* Create the bit array serving as mask. */
4999 row_width = (img->width + 7) / 8; 4842 row_width = (img->width + 7) / 8;
5000 mask_img = xmalloc (row_width * img->height); 4843 mask_img = xmalloc (row_width * img->height);
5001 bzero (mask_img, row_width * img->height); 4844 memset (mask_img, 0, row_width * img->height);
5002 4845
5003 /* Create a memory device context for IMG->pixmap. */ 4846 /* Create a memory device context for IMG->pixmap. */
5004 frame_dc = get_frame_dc (f); 4847 frame_dc = get_frame_dc (f);
@@ -5046,8 +4889,8 @@ x_build_heuristic_mask (f, img, how)
5046 XPutPixel (mask_img, x, y, (XGetPixel (ximg, x, y) != bg 4889 XPutPixel (mask_img, x, y, (XGetPixel (ximg, x, y) != bg
5047 ? PIX_MASK_DRAW : PIX_MASK_RETAIN)); 4890 ? PIX_MASK_DRAW : PIX_MASK_RETAIN));
5048#else 4891#else
5049 if (XGetPixel (ximg, x, y) == bg) 4892 if (XGetPixel (ximg, x, y) == bg)
5050 ns_set_alpha(ximg, x, y, 0); 4893 ns_set_alpha (ximg, x, y, 0);
5051#endif /* HAVE_NS */ 4894#endif /* HAVE_NS */
5052#ifndef HAVE_NS 4895#ifndef HAVE_NS
5053 /* Fill in the background_transparent field while we have the mask handy. */ 4896 /* Fill in the background_transparent field while we have the mask handy. */
@@ -5087,9 +4930,9 @@ x_build_heuristic_mask (f, img, how)
5087 PBM (mono, gray, color) 4930 PBM (mono, gray, color)
5088***********************************************************************/ 4931***********************************************************************/
5089 4932
5090static int pbm_image_p P_ ((Lisp_Object object)); 4933static int pbm_image_p (Lisp_Object object);
5091static int pbm_load P_ ((struct frame *f, struct image *img)); 4934static int pbm_load (struct frame *f, struct image *img);
5092static int pbm_scan_number P_ ((unsigned char **, unsigned char *)); 4935static int pbm_scan_number (unsigned char **, unsigned char *);
5093 4936
5094/* The symbol `pbm' identifying images of this type. */ 4937/* The symbol `pbm' identifying images of this type. */
5095 4938
@@ -5146,12 +4989,11 @@ static struct image_type pbm_type =
5146/* Return non-zero if OBJECT is a valid PBM image specification. */ 4989/* Return non-zero if OBJECT is a valid PBM image specification. */
5147 4990
5148static int 4991static int
5149pbm_image_p (object) 4992pbm_image_p (Lisp_Object object)
5150 Lisp_Object object;
5151{ 4993{
5152 struct image_keyword fmt[PBM_LAST]; 4994 struct image_keyword fmt[PBM_LAST];
5153 4995
5154 bcopy (pbm_format, fmt, sizeof fmt); 4996 memcpy (fmt, pbm_format, sizeof fmt);
5155 4997
5156 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)) 4998 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm))
5157 return 0; 4999 return 0;
@@ -5166,8 +5008,7 @@ pbm_image_p (object)
5166 end of input. */ 5008 end of input. */
5167 5009
5168static int 5010static int
5169pbm_scan_number (s, end) 5011pbm_scan_number (unsigned char **s, unsigned char *end)
5170 unsigned char **s, *end;
5171{ 5012{
5172 int c = 0, val = -1; 5013 int c = 0, val = -1;
5173 5014
@@ -5242,9 +5083,7 @@ pbm_read_file (file, size)
5242/* Load PBM image IMG for use on frame F. */ 5083/* Load PBM image IMG for use on frame F. */
5243 5084
5244static int 5085static int
5245pbm_load (f, img) 5086pbm_load (struct frame *f, struct image *img)
5246 struct frame *f;
5247 struct image *img;
5248{ 5087{
5249 int raw_p, x, y; 5088 int raw_p, x, y;
5250 int width, height, max_color_idx = 0; 5089 int width, height, max_color_idx = 0;
@@ -5366,7 +5205,7 @@ pbm_load (f, img)
5366 unsigned long bg = FRAME_BACKGROUND_PIXEL (f); 5205 unsigned long bg = FRAME_BACKGROUND_PIXEL (f);
5367 5206
5368 /* Parse the image specification. */ 5207 /* Parse the image specification. */
5369 bcopy (pbm_format, fmt, sizeof fmt); 5208 memcpy (fmt, pbm_format, sizeof fmt);
5370 parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm); 5209 parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm);
5371 5210
5372 /* Get foreground and background colors, maybe allocate colors. */ 5211 /* Get foreground and background colors, maybe allocate colors. */
@@ -5511,8 +5350,8 @@ pbm_load (f, img)
5511 5350
5512/* Function prototypes. */ 5351/* Function prototypes. */
5513 5352
5514static int png_image_p P_ ((Lisp_Object object)); 5353static int png_image_p (Lisp_Object object);
5515static int png_load P_ ((struct frame *f, struct image *img)); 5354static int png_load (struct frame *f, struct image *img);
5516 5355
5517/* The symbol `png' identifying images of this type. */ 5356/* The symbol `png' identifying images of this type. */
5518 5357
@@ -5566,11 +5405,10 @@ static struct image_type png_type =
5566/* Return non-zero if OBJECT is a valid PNG image specification. */ 5405/* Return non-zero if OBJECT is a valid PNG image specification. */
5567 5406
5568static int 5407static int
5569png_image_p (object) 5408png_image_p (Lisp_Object object)
5570 Lisp_Object object;
5571{ 5409{
5572 struct image_keyword fmt[PNG_LAST]; 5410 struct image_keyword fmt[PNG_LAST];
5573 bcopy (png_format, fmt, sizeof fmt); 5411 memcpy (fmt, png_format, sizeof fmt);
5574 5412
5575 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)) 5413 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng))
5576 return 0; 5414 return 0;
@@ -5671,9 +5509,7 @@ init_png_functions (Lisp_Object libraries)
5671 is initialized. */ 5509 is initialized. */
5672 5510
5673static void 5511static void
5674my_png_error (png_ptr, msg) 5512my_png_error (png_struct *png_ptr, const char *msg)
5675 png_struct *png_ptr;
5676 char *msg;
5677{ 5513{
5678 xassert (png_ptr != NULL); 5514 xassert (png_ptr != NULL);
5679 image_error ("PNG error: %s", build_string (msg), Qnil); 5515 image_error ("PNG error: %s", build_string (msg), Qnil);
@@ -5682,9 +5518,7 @@ my_png_error (png_ptr, msg)
5682 5518
5683 5519
5684static void 5520static void
5685my_png_warning (png_ptr, msg) 5521my_png_warning (png_struct *png_ptr, const char *msg)
5686 png_struct *png_ptr;
5687 char *msg;
5688{ 5522{
5689 xassert (png_ptr != NULL); 5523 xassert (png_ptr != NULL);
5690 image_error ("PNG warning: %s", build_string (msg), Qnil); 5524 image_error ("PNG warning: %s", build_string (msg), Qnil);
@@ -5705,10 +5539,7 @@ struct png_memory_storage
5705 bytes from the input to DATA. */ 5539 bytes from the input to DATA. */
5706 5540
5707static void 5541static void
5708png_read_from_memory (png_ptr, data, length) 5542png_read_from_memory (png_structp png_ptr, png_bytep data, png_size_t length)
5709 png_structp png_ptr;
5710 png_bytep data;
5711 png_size_t length;
5712{ 5543{
5713 struct png_memory_storage *tbr 5544 struct png_memory_storage *tbr
5714 = (struct png_memory_storage *) fn_png_get_io_ptr (png_ptr); 5545 = (struct png_memory_storage *) fn_png_get_io_ptr (png_ptr);
@@ -5716,7 +5547,7 @@ png_read_from_memory (png_ptr, data, length)
5716 if (length > tbr->len - tbr->index) 5547 if (length > tbr->len - tbr->index)
5717 fn_png_error (png_ptr, "Read error"); 5548 fn_png_error (png_ptr, "Read error");
5718 5549
5719 bcopy (tbr->bytes + tbr->index, data, length); 5550 memcpy (data, tbr->bytes + tbr->index, length);
5720 tbr->index = tbr->index + length; 5551 tbr->index = tbr->index + length;
5721} 5552}
5722 5553
@@ -5726,10 +5557,7 @@ png_read_from_memory (png_ptr, data, length)
5726 bytes from the input to DATA. */ 5557 bytes from the input to DATA. */
5727 5558
5728static void 5559static void
5729png_read_from_file (png_ptr, data, length) 5560png_read_from_file (png_structp png_ptr, png_bytep data, png_size_t length)
5730 png_structp png_ptr;
5731 png_bytep data;
5732 png_size_t length;
5733{ 5561{
5734 FILE *fp = (FILE *) fn_png_get_io_ptr (png_ptr); 5562 FILE *fp = (FILE *) fn_png_get_io_ptr (png_ptr);
5735 5563
@@ -5742,9 +5570,7 @@ png_read_from_file (png_ptr, data, length)
5742 successful. */ 5570 successful. */
5743 5571
5744static int 5572static int
5745png_load (f, img) 5573png_load (struct frame *f, struct image *img)
5746 struct frame *f;
5747 struct image *img;
5748{ 5574{
5749 Lisp_Object file, specified_file; 5575 Lisp_Object file, specified_file;
5750 Lisp_Object specified_data; 5576 Lisp_Object specified_data;
@@ -5923,7 +5749,7 @@ png_load (f, img)
5923 { 5749 {
5924 png_color_16 user_bg; 5750 png_color_16 user_bg;
5925 5751
5926 bzero (&user_bg, sizeof user_bg); 5752 memset (&user_bg, 0, sizeof user_bg);
5927 user_bg.red = color.red >> shift; 5753 user_bg.red = color.red >> shift;
5928 user_bg.green = color.green >> shift; 5754 user_bg.green = color.green >> shift;
5929 user_bg.blue = color.blue >> shift; 5755 user_bg.blue = color.blue >> shift;
@@ -5943,7 +5769,7 @@ png_load (f, img)
5943 color.pixel = FRAME_BACKGROUND_PIXEL (f); 5769 color.pixel = FRAME_BACKGROUND_PIXEL (f);
5944 x_query_color (f, &color); 5770 x_query_color (f, &color);
5945 5771
5946 bzero (&frame_background, sizeof frame_background); 5772 memset (&frame_background, 0, sizeof frame_background);
5947 frame_background.red = color.red >> shift; 5773 frame_background.red = color.red >> shift;
5948 frame_background.green = color.green >> shift; 5774 frame_background.green = color.green >> shift;
5949 frame_background.blue = color.blue >> shift; 5775 frame_background.blue = color.blue >> shift;
@@ -6113,8 +5939,8 @@ png_load (struct frame *f, struct image *img)
6113 5939
6114#if defined (HAVE_JPEG) || defined (HAVE_NS) 5940#if defined (HAVE_JPEG) || defined (HAVE_NS)
6115 5941
6116static int jpeg_image_p P_ ((Lisp_Object object)); 5942static int jpeg_image_p (Lisp_Object object);
6117static int jpeg_load P_ ((struct frame *f, struct image *img)); 5943static int jpeg_load (struct frame *f, struct image *img);
6118 5944
6119/* The symbol `jpeg' identifying images of this type. */ 5945/* The symbol `jpeg' identifying images of this type. */
6120 5946
@@ -6168,12 +5994,11 @@ static struct image_type jpeg_type =
6168/* Return non-zero if OBJECT is a valid JPEG image specification. */ 5994/* Return non-zero if OBJECT is a valid JPEG image specification. */
6169 5995
6170static int 5996static int
6171jpeg_image_p (object) 5997jpeg_image_p (Lisp_Object object)
6172 Lisp_Object object;
6173{ 5998{
6174 struct image_keyword fmt[JPEG_LAST]; 5999 struct image_keyword fmt[JPEG_LAST];
6175 6000
6176 bcopy (jpeg_format, fmt, sizeof fmt); 6001 memcpy (fmt, jpeg_format, sizeof fmt);
6177 6002
6178 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)) 6003 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg))
6179 return 0; 6004 return 0;
@@ -6240,9 +6065,7 @@ init_jpeg_functions (Lisp_Object libraries)
6240/* Wrapper since we can't directly assign the function pointer 6065/* Wrapper since we can't directly assign the function pointer
6241 to another function pointer that was declared more completely easily. */ 6066 to another function pointer that was declared more completely easily. */
6242static boolean 6067static boolean
6243jpeg_resync_to_restart_wrapper (cinfo, desired) 6068jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired)
6244 j_decompress_ptr cinfo;
6245 int desired;
6246{ 6069{
6247 return fn_jpeg_resync_to_restart (cinfo, desired); 6070 return fn_jpeg_resync_to_restart (cinfo, desired);
6248} 6071}
@@ -6268,8 +6091,7 @@ struct my_jpeg_error_mgr
6268 6091
6269 6092
6270static void 6093static void
6271my_error_exit (cinfo) 6094my_error_exit (j_common_ptr cinfo)
6272 j_common_ptr cinfo;
6273{ 6095{
6274 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; 6096 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err;
6275 longjmp (mgr->setjmp_buffer, 1); 6097 longjmp (mgr->setjmp_buffer, 1);
@@ -6281,8 +6103,7 @@ my_error_exit (cinfo)
6281 libjpeg.doc from the JPEG lib distribution. */ 6103 libjpeg.doc from the JPEG lib distribution. */
6282 6104
6283static void 6105static void
6284our_common_init_source (cinfo) 6106our_common_init_source (j_decompress_ptr cinfo)
6285 j_decompress_ptr cinfo;
6286{ 6107{
6287} 6108}
6288 6109
@@ -6291,8 +6112,7 @@ our_common_init_source (cinfo)
6291 jpeg_finish_decompress() after all data has been processed. */ 6112 jpeg_finish_decompress() after all data has been processed. */
6292 6113
6293static void 6114static void
6294our_common_term_source (cinfo) 6115our_common_term_source (j_decompress_ptr cinfo)
6295 j_decompress_ptr cinfo;
6296{ 6116{
6297} 6117}
6298 6118
@@ -6304,8 +6124,7 @@ our_common_term_source (cinfo)
6304static JOCTET our_memory_buffer[2]; 6124static JOCTET our_memory_buffer[2];
6305 6125
6306static boolean 6126static boolean
6307our_memory_fill_input_buffer (cinfo) 6127our_memory_fill_input_buffer (j_decompress_ptr cinfo)
6308 j_decompress_ptr cinfo;
6309{ 6128{
6310 /* Insert a fake EOI marker. */ 6129 /* Insert a fake EOI marker. */
6311 struct jpeg_source_mgr *src = cinfo->src; 6130 struct jpeg_source_mgr *src = cinfo->src;
@@ -6323,9 +6142,7 @@ our_memory_fill_input_buffer (cinfo)
6323 is the JPEG data source manager. */ 6142 is the JPEG data source manager. */
6324 6143
6325static void 6144static void
6326our_memory_skip_input_data (cinfo, num_bytes) 6145our_memory_skip_input_data (j_decompress_ptr cinfo, long int num_bytes)
6327 j_decompress_ptr cinfo;
6328 long num_bytes;
6329{ 6146{
6330 struct jpeg_source_mgr *src = (struct jpeg_source_mgr *) cinfo->src; 6147 struct jpeg_source_mgr *src = (struct jpeg_source_mgr *) cinfo->src;
6331 6148
@@ -6345,10 +6162,7 @@ our_memory_skip_input_data (cinfo, num_bytes)
6345 reading the image. */ 6162 reading the image. */
6346 6163
6347static void 6164static void
6348jpeg_memory_src (cinfo, data, len) 6165jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, unsigned int len)
6349 j_decompress_ptr cinfo;
6350 JOCTET *data;
6351 unsigned int len;
6352{ 6166{
6353 struct jpeg_source_mgr *src; 6167 struct jpeg_source_mgr *src;
6354 6168
@@ -6391,8 +6205,7 @@ struct jpeg_stdio_mgr
6391 whenever more data is needed. The data is read from a FILE *. */ 6205 whenever more data is needed. The data is read from a FILE *. */
6392 6206
6393static boolean 6207static boolean
6394our_stdio_fill_input_buffer (cinfo) 6208our_stdio_fill_input_buffer (j_decompress_ptr cinfo)
6395 j_decompress_ptr cinfo;
6396{ 6209{
6397 struct jpeg_stdio_mgr *src; 6210 struct jpeg_stdio_mgr *src;
6398 6211
@@ -6423,9 +6236,7 @@ our_stdio_fill_input_buffer (cinfo)
6423 is the JPEG data source manager. */ 6236 is the JPEG data source manager. */
6424 6237
6425static void 6238static void
6426our_stdio_skip_input_data (cinfo, num_bytes) 6239our_stdio_skip_input_data (j_decompress_ptr cinfo, long int num_bytes)
6427 j_decompress_ptr cinfo;
6428 long num_bytes;
6429{ 6240{
6430 struct jpeg_stdio_mgr *src; 6241 struct jpeg_stdio_mgr *src;
6431 src = (struct jpeg_stdio_mgr *) cinfo->src; 6242 src = (struct jpeg_stdio_mgr *) cinfo->src;
@@ -6455,9 +6266,7 @@ our_stdio_skip_input_data (cinfo, num_bytes)
6455 reading the image. */ 6266 reading the image. */
6456 6267
6457static void 6268static void
6458jpeg_file_src (cinfo, fp) 6269jpeg_file_src (j_decompress_ptr cinfo, FILE *fp)
6459 j_decompress_ptr cinfo;
6460 FILE *fp;
6461{ 6270{
6462 struct jpeg_stdio_mgr *src; 6271 struct jpeg_stdio_mgr *src;
6463 6272
@@ -6491,9 +6300,7 @@ jpeg_file_src (cinfo, fp)
6491 from the JPEG lib. */ 6300 from the JPEG lib. */
6492 6301
6493static int 6302static int
6494jpeg_load (f, img) 6303jpeg_load (struct frame *f, struct image *img)
6495 struct frame *f;
6496 struct image *img;
6497{ 6304{
6498 struct jpeg_decompress_struct cinfo; 6305 struct jpeg_decompress_struct cinfo;
6499 struct my_jpeg_error_mgr mgr; 6306 struct my_jpeg_error_mgr mgr;
@@ -6669,9 +6476,9 @@ jpeg_load (f, img)
6669static int 6476static int
6670jpeg_load (struct frame *f, struct image *img) 6477jpeg_load (struct frame *f, struct image *img)
6671{ 6478{
6672 return ns_load_image(f, img, 6479 return ns_load_image (f, img,
6673 image_spec_value (img->spec, QCfile, NULL), 6480 image_spec_value (img->spec, QCfile, NULL),
6674 image_spec_value (img->spec, QCdata, NULL)); 6481 image_spec_value (img->spec, QCdata, NULL));
6675} 6482}
6676#endif /* HAVE_NS */ 6483#endif /* HAVE_NS */
6677 6484
@@ -6685,8 +6492,8 @@ jpeg_load (struct frame *f, struct image *img)
6685 6492
6686#if defined (HAVE_TIFF) || defined (HAVE_NS) 6493#if defined (HAVE_TIFF) || defined (HAVE_NS)
6687 6494
6688static int tiff_image_p P_ ((Lisp_Object object)); 6495static int tiff_image_p (Lisp_Object object);
6689static int tiff_load P_ ((struct frame *f, struct image *img)); 6496static int tiff_load (struct frame *f, struct image *img);
6690 6497
6691/* The symbol `tiff' identifying images of this type. */ 6498/* The symbol `tiff' identifying images of this type. */
6692 6499
@@ -6742,11 +6549,10 @@ static struct image_type tiff_type =
6742/* Return non-zero if OBJECT is a valid TIFF image specification. */ 6549/* Return non-zero if OBJECT is a valid TIFF image specification. */
6743 6550
6744static int 6551static int
6745tiff_image_p (object) 6552tiff_image_p (Lisp_Object object)
6746 Lisp_Object object;
6747{ 6553{
6748 struct image_keyword fmt[TIFF_LAST]; 6554 struct image_keyword fmt[TIFF_LAST];
6749 bcopy (tiff_format, fmt, sizeof fmt); 6555 memcpy (fmt, tiff_format, sizeof fmt);
6750 6556
6751 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)) 6557 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff))
6752 return 0; 6558 return 0;
@@ -6823,34 +6629,25 @@ typedef struct
6823 tiff_memory_source; 6629 tiff_memory_source;
6824 6630
6825static size_t 6631static size_t
6826tiff_read_from_memory (data, buf, size) 6632tiff_read_from_memory (thandle_t data, tdata_t buf, tsize_t size)
6827 thandle_t data;
6828 tdata_t buf;
6829 tsize_t size;
6830{ 6633{
6831 tiff_memory_source *src = (tiff_memory_source *) data; 6634 tiff_memory_source *src = (tiff_memory_source *) data;
6832 6635
6833 if (size > src->len - src->index) 6636 if (size > src->len - src->index)
6834 return (size_t) -1; 6637 return (size_t) -1;
6835 bcopy (src->bytes + src->index, buf, size); 6638 memcpy (buf, src->bytes + src->index, size);
6836 src->index += size; 6639 src->index += size;
6837 return size; 6640 return size;
6838} 6641}
6839 6642
6840static size_t 6643static size_t
6841tiff_write_from_memory (data, buf, size) 6644tiff_write_from_memory (thandle_t data, tdata_t buf, tsize_t size)
6842 thandle_t data;
6843 tdata_t buf;
6844 tsize_t size;
6845{ 6645{
6846 return (size_t) -1; 6646 return (size_t) -1;
6847} 6647}
6848 6648
6849static toff_t 6649static toff_t
6850tiff_seek_in_memory (data, off, whence) 6650tiff_seek_in_memory (thandle_t data, toff_t off, int whence)
6851 thandle_t data;
6852 toff_t off;
6853 int whence;
6854{ 6651{
6855 tiff_memory_source *src = (tiff_memory_source *) data; 6652 tiff_memory_source *src = (tiff_memory_source *) data;
6856 int idx; 6653 int idx;
@@ -6881,44 +6678,34 @@ tiff_seek_in_memory (data, off, whence)
6881} 6678}
6882 6679
6883static int 6680static int
6884tiff_close_memory (data) 6681tiff_close_memory (thandle_t data)
6885 thandle_t data;
6886{ 6682{
6887 /* NOOP */ 6683 /* NOOP */
6888 return 0; 6684 return 0;
6889} 6685}
6890 6686
6891static int 6687static int
6892tiff_mmap_memory (data, pbase, psize) 6688tiff_mmap_memory (thandle_t data, tdata_t *pbase, toff_t *psize)
6893 thandle_t data;
6894 tdata_t *pbase;
6895 toff_t *psize;
6896{ 6689{
6897 /* It is already _IN_ memory. */ 6690 /* It is already _IN_ memory. */
6898 return 0; 6691 return 0;
6899} 6692}
6900 6693
6901static void 6694static void
6902tiff_unmap_memory (data, base, size) 6695tiff_unmap_memory (thandle_t data, tdata_t base, toff_t size)
6903 thandle_t data;
6904 tdata_t base;
6905 toff_t size;
6906{ 6696{
6907 /* We don't need to do this. */ 6697 /* We don't need to do this. */
6908} 6698}
6909 6699
6910static toff_t 6700static toff_t
6911tiff_size_of_memory (data) 6701tiff_size_of_memory (thandle_t data)
6912 thandle_t data;
6913{ 6702{
6914 return ((tiff_memory_source *) data)->len; 6703 return ((tiff_memory_source *) data)->len;
6915} 6704}
6916 6705
6917 6706
6918static void 6707static void
6919tiff_error_handler (title, format, ap) 6708tiff_error_handler (const char *title, const char *format, va_list ap)
6920 const char *title, *format;
6921 va_list ap;
6922{ 6709{
6923 char buf[512]; 6710 char buf[512];
6924 int len; 6711 int len;
@@ -6930,9 +6717,7 @@ tiff_error_handler (title, format, ap)
6930 6717
6931 6718
6932static void 6719static void
6933tiff_warning_handler (title, format, ap) 6720tiff_warning_handler (const char *title, const char *format, va_list ap)
6934 const char *title, *format;
6935 va_list ap;
6936{ 6721{
6937 char buf[512]; 6722 char buf[512];
6938 int len; 6723 int len;
@@ -6947,9 +6732,7 @@ tiff_warning_handler (title, format, ap)
6947 successful. */ 6732 successful. */
6948 6733
6949static int 6734static int
6950tiff_load (f, img) 6735tiff_load (struct frame *f, struct image *img)
6951 struct frame *f;
6952 struct image *img;
6953{ 6736{
6954 Lisp_Object file, specified_file; 6737 Lisp_Object file, specified_file;
6955 Lisp_Object specified_data; 6738 Lisp_Object specified_data;
@@ -7120,9 +6903,9 @@ tiff_load (f, img)
7120static int 6903static int
7121tiff_load (struct frame *f, struct image *img) 6904tiff_load (struct frame *f, struct image *img)
7122{ 6905{
7123 return ns_load_image(f, img, 6906 return ns_load_image (f, img,
7124 image_spec_value (img->spec, QCfile, NULL), 6907 image_spec_value (img->spec, QCfile, NULL),
7125 image_spec_value (img->spec, QCdata, NULL)); 6908 image_spec_value (img->spec, QCdata, NULL));
7126} 6909}
7127#endif /* HAVE_NS */ 6910#endif /* HAVE_NS */
7128 6911
@@ -7136,9 +6919,9 @@ tiff_load (struct frame *f, struct image *img)
7136 6919
7137#if defined (HAVE_GIF) || defined (HAVE_NS) 6920#if defined (HAVE_GIF) || defined (HAVE_NS)
7138 6921
7139static int gif_image_p P_ ((Lisp_Object object)); 6922static int gif_image_p (Lisp_Object object);
7140static int gif_load P_ ((struct frame *f, struct image *img)); 6923static int gif_load (struct frame *f, struct image *img);
7141static void gif_clear_image P_ ((struct frame *f, struct image *img)); 6924static void gif_clear_image (struct frame *f, struct image *img);
7142 6925
7143/* The symbol `gif' identifying images of this type. */ 6926/* The symbol `gif' identifying images of this type. */
7144 6927
@@ -7194,9 +6977,7 @@ static struct image_type gif_type =
7194/* Free X resources of GIF image IMG which is used on frame F. */ 6977/* Free X resources of GIF image IMG which is used on frame F. */
7195 6978
7196static void 6979static void
7197gif_clear_image (f, img) 6980gif_clear_image (struct frame *f, struct image *img)
7198 struct frame *f;
7199 struct image *img;
7200{ 6981{
7201 /* IMG->data.ptr_val may contain metadata with extension data. */ 6982 /* IMG->data.ptr_val may contain metadata with extension data. */
7202 img->data.lisp_val = Qnil; 6983 img->data.lisp_val = Qnil;
@@ -7206,11 +6987,10 @@ gif_clear_image (f, img)
7206/* Return non-zero if OBJECT is a valid GIF image specification. */ 6987/* Return non-zero if OBJECT is a valid GIF image specification. */
7207 6988
7208static int 6989static int
7209gif_image_p (object) 6990gif_image_p (Lisp_Object object)
7210 Lisp_Object object;
7211{ 6991{
7212 struct image_keyword fmt[GIF_LAST]; 6992 struct image_keyword fmt[GIF_LAST];
7213 bcopy (gif_format, fmt, sizeof fmt); 6993 memcpy (fmt, gif_format, sizeof fmt);
7214 6994
7215 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)) 6995 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif))
7216 return 0; 6996 return 0;
@@ -7290,17 +7070,14 @@ typedef struct
7290static gif_memory_source *current_gif_memory_src; 7070static gif_memory_source *current_gif_memory_src;
7291 7071
7292static int 7072static int
7293gif_read_from_memory (file, buf, len) 7073gif_read_from_memory (GifFileType *file, GifByteType *buf, int len)
7294 GifFileType *file;
7295 GifByteType *buf;
7296 int len;
7297{ 7074{
7298 gif_memory_source *src = current_gif_memory_src; 7075 gif_memory_source *src = current_gif_memory_src;
7299 7076
7300 if (len > src->len - src->index) 7077 if (len > src->len - src->index)
7301 return -1; 7078 return -1;
7302 7079
7303 bcopy (src->bytes + src->index, buf, len); 7080 memcpy (buf, src->bytes + src->index, len);
7304 src->index += len; 7081 src->index += len;
7305 return len; 7082 return len;
7306} 7083}
@@ -7313,9 +7090,7 @@ static const int interlace_start[] = {0, 4, 2, 1};
7313static const int interlace_increment[] = {8, 8, 4, 2}; 7090static const int interlace_increment[] = {8, 8, 4, 2};
7314 7091
7315static int 7092static int
7316gif_load (f, img) 7093gif_load (struct frame *f, struct image *img)
7317 struct frame *f;
7318 struct image *img;
7319{ 7094{
7320 Lisp_Object file, specified_file; 7095 Lisp_Object file, specified_file;
7321 Lisp_Object specified_data; 7096 Lisp_Object specified_data;
@@ -7438,7 +7213,7 @@ gif_load (f, img)
7438 if (!gif_color_map) 7213 if (!gif_color_map)
7439 gif_color_map = gif->SColorMap; 7214 gif_color_map = gif->SColorMap;
7440 init_color_table (); 7215 init_color_table ();
7441 bzero (pixel_colors, sizeof pixel_colors); 7216 memset (pixel_colors, 0, sizeof pixel_colors);
7442 7217
7443 if (gif_color_map) 7218 if (gif_color_map)
7444 for (i = 0; i < gif_color_map->ColorCount; ++i) 7219 for (i = 0; i < gif_color_map->ColorCount; ++i)
@@ -7558,9 +7333,9 @@ gif_load (f, img)
7558static int 7333static int
7559gif_load (struct frame *f, struct image *img) 7334gif_load (struct frame *f, struct image *img)
7560{ 7335{
7561 return ns_load_image(f, img, 7336 return ns_load_image (f, img,
7562 image_spec_value (img->spec, QCfile, NULL), 7337 image_spec_value (img->spec, QCfile, NULL),
7563 image_spec_value (img->spec, QCdata, NULL)); 7338 image_spec_value (img->spec, QCdata, NULL));
7564} 7339}
7565#endif /* HAVE_NS */ 7340#endif /* HAVE_NS */
7566 7341
@@ -7676,8 +7451,8 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */
7676 contents/size. */ 7451 contents/size. */
7677 unsigned char *filename) 7452 unsigned char *filename)
7678{ 7453{
7679 long unsigned int width; 7454 size_t width;
7680 long unsigned int height; 7455 size_t height;
7681 7456
7682 MagickBooleanType 7457 MagickBooleanType
7683 status; 7458 status;
@@ -8075,10 +7850,10 @@ DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0,
8075 doc: /* Return image file types supported by ImageMagick. 7850 doc: /* Return image file types supported by ImageMagick.
8076 Since ImageMagick recognizes a lot of file-types that clash with Emacs, 7851 Since ImageMagick recognizes a lot of file-types that clash with Emacs,
8077 such as .c, we want to be able to alter the list at the lisp level. */) 7852 such as .c, we want to be able to alter the list at the lisp level. */)
8078 () 7853 (void)
8079{ 7854{
8080 Lisp_Object typelist = Qnil; 7855 Lisp_Object typelist = Qnil;
8081 unsigned long numf; 7856 size_t numf;
8082 ExceptionInfo ex; 7857 ExceptionInfo ex;
8083 char** imtypes = GetMagickList ("*", &numf, &ex); 7858 char** imtypes = GetMagickList ("*", &numf, &ex);
8084 int i; 7859 int i;
@@ -8103,11 +7878,11 @@ DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0,
8103 7878
8104/* Function prototypes. */ 7879/* Function prototypes. */
8105 7880
8106static int svg_image_p P_ ((Lisp_Object object)); 7881static int svg_image_p (Lisp_Object object);
8107static int svg_load P_ ((struct frame *f, struct image *img)); 7882static int svg_load (struct frame *f, struct image *img);
8108 7883
8109static int svg_load_image P_ ((struct frame *, struct image *, 7884static int svg_load_image (struct frame *, struct image *,
8110 unsigned char *, unsigned int)); 7885 unsigned char *, unsigned int);
8111 7886
8112/* The symbol `svg' identifying images of this type. */ 7887/* The symbol `svg' identifying images of this type. */
8113 7888
@@ -8172,11 +7947,10 @@ static struct image_type svg_type =
8172 identify the SVG format. */ 7947 identify the SVG format. */
8173 7948
8174static int 7949static int
8175svg_image_p (object) 7950svg_image_p (Lisp_Object object)
8176 Lisp_Object object;
8177{ 7951{
8178 struct image_keyword fmt[SVG_LAST]; 7952 struct image_keyword fmt[SVG_LAST];
8179 bcopy (svg_format, fmt, sizeof fmt); 7953 memcpy (fmt, svg_format, sizeof fmt);
8180 7954
8181 if (!parse_image_spec (object, fmt, SVG_LAST, Qsvg)) 7955 if (!parse_image_spec (object, fmt, SVG_LAST, Qsvg))
8182 return 0; 7956 return 0;
@@ -8275,9 +8049,7 @@ init_svg_functions (Lisp_Object libraries)
8275 the prototype thus needs to be compatible with that structure. */ 8049 the prototype thus needs to be compatible with that structure. */
8276 8050
8277static int 8051static int
8278svg_load (f, img) 8052svg_load (struct frame *f, struct image *img)
8279 struct frame *f;
8280 struct image *img;
8281{ 8053{
8282 int success_p = 0; 8054 int success_p = 0;
8283 Lisp_Object file_name; 8055 Lisp_Object file_name;
@@ -8334,15 +8106,10 @@ svg_load (f, img)
8334 8106
8335 Returns non-zero when successful. */ 8107 Returns non-zero when successful. */
8336static int 8108static int
8337svg_load_image (f, img, contents, size) 8109svg_load_image (struct frame *f, /* Pointer to emacs frame structure. */
8338/* Pointer to emacs frame structure. */ 8110 struct image *img, /* Pointer to emacs image structure. */
8339 struct frame *f; 8111 unsigned char *contents, /* String containing the SVG XML data to be parsed. */
8340 /* Pointer to emacs image structure. */ 8112 unsigned int size) /* Size of data in bytes. */
8341 struct image *img;
8342 /* String containing the SVG XML data to be parsed. */
8343 unsigned char *contents;
8344 /* Size of data in bytes. */
8345 unsigned int size;
8346{ 8113{
8347 RsvgHandle *rsvg_handle; 8114 RsvgHandle *rsvg_handle;
8348 RsvgDimensionData dimension_data; 8115 RsvgDimensionData dimension_data;
@@ -8417,7 +8184,7 @@ svg_load_image (f, img, contents, size)
8417 background.pixel = FRAME_BACKGROUND_PIXEL (f); 8184 background.pixel = FRAME_BACKGROUND_PIXEL (f);
8418 x_query_color (f, &background); 8185 x_query_color (f, &background);
8419#else 8186#else
8420 ns_query_color(FRAME_BACKGROUND_COLOR (f), &background, 1); 8187 ns_query_color (FRAME_BACKGROUND_COLOR (f), &background, 1);
8421#endif 8188#endif
8422 } 8189 }
8423 8190
@@ -8503,15 +8270,11 @@ svg_load_image (f, img, contents, size)
8503#define HAVE_GHOSTSCRIPT 1 8270#define HAVE_GHOSTSCRIPT 1
8504#endif /* HAVE_X_WINDOWS */ 8271#endif /* HAVE_X_WINDOWS */
8505 8272
8506/* The symbol `postscript' identifying images of this type. */
8507
8508Lisp_Object Qpostscript;
8509
8510#ifdef HAVE_GHOSTSCRIPT 8273#ifdef HAVE_GHOSTSCRIPT
8511 8274
8512static int gs_image_p P_ ((Lisp_Object object)); 8275static int gs_image_p (Lisp_Object object);
8513static int gs_load P_ ((struct frame *f, struct image *img)); 8276static int gs_load (struct frame *f, struct image *img);
8514static void gs_clear_image P_ ((struct frame *f, struct image *img)); 8277static void gs_clear_image (struct frame *f, struct image *img);
8515 8278
8516/* Keyword symbols. */ 8279/* Keyword symbols. */
8517 8280
@@ -8572,9 +8335,7 @@ static struct image_type gs_type =
8572/* Free X resources of Ghostscript image IMG which is used on frame F. */ 8335/* Free X resources of Ghostscript image IMG which is used on frame F. */
8573 8336
8574static void 8337static void
8575gs_clear_image (f, img) 8338gs_clear_image (struct frame *f, struct image *img)
8576 struct frame *f;
8577 struct image *img;
8578{ 8339{
8579 /* IMG->data.ptr_val may contain a recorded colormap. */ 8340 /* IMG->data.ptr_val may contain a recorded colormap. */
8580 xfree (img->data.ptr_val); 8341 xfree (img->data.ptr_val);
@@ -8586,14 +8347,13 @@ gs_clear_image (f, img)
8586 specification. */ 8347 specification. */
8587 8348
8588static int 8349static int
8589gs_image_p (object) 8350gs_image_p (Lisp_Object object)
8590 Lisp_Object object;
8591{ 8351{
8592 struct image_keyword fmt[GS_LAST]; 8352 struct image_keyword fmt[GS_LAST];
8593 Lisp_Object tem; 8353 Lisp_Object tem;
8594 int i; 8354 int i;
8595 8355
8596 bcopy (gs_format, fmt, sizeof fmt); 8356 memcpy (fmt, gs_format, sizeof fmt);
8597 8357
8598 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)) 8358 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript))
8599 return 0; 8359 return 0;
@@ -8627,9 +8387,7 @@ gs_image_p (object)
8627 if successful. */ 8387 if successful. */
8628 8388
8629static int 8389static int
8630gs_load (f, img) 8390gs_load (struct frame *f, struct image *img)
8631 struct frame *f;
8632 struct image *img;
8633{ 8391{
8634 char buffer[100]; 8392 char buffer[100];
8635 Lisp_Object window_and_pixmap_id = Qnil, loader, pt_height, pt_width; 8393 Lisp_Object window_and_pixmap_id = Qnil, loader, pt_height, pt_width;
@@ -8707,9 +8465,7 @@ gs_load (f, img)
8707 telling Emacs that Ghostscript has finished drawing. */ 8465 telling Emacs that Ghostscript has finished drawing. */
8708 8466
8709void 8467void
8710x_kill_gs_process (pixmap, f) 8468x_kill_gs_process (Pixmap pixmap, struct frame *f)
8711 Pixmap pixmap;
8712 struct frame *f;
8713{ 8469{
8714 struct image_cache *c = FRAME_IMAGE_CACHE (f); 8470 struct image_cache *c = FRAME_IMAGE_CACHE (f);
8715 int class, i; 8471 int class, i;
@@ -8807,16 +8563,14 @@ x_kill_gs_process (pixmap, f)
8807 8563
8808DEFUN ("imagep", Fimagep, Simagep, 1, 1, 0, 8564DEFUN ("imagep", Fimagep, Simagep, 1, 1, 0,
8809 doc: /* Value is non-nil if SPEC is a valid image specification. */) 8565 doc: /* Value is non-nil if SPEC is a valid image specification. */)
8810 (spec) 8566 (Lisp_Object spec)
8811 Lisp_Object spec;
8812{ 8567{
8813 return valid_image_p (spec) ? Qt : Qnil; 8568 return valid_image_p (spec) ? Qt : Qnil;
8814} 8569}
8815 8570
8816 8571
8817DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "") 8572DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "")
8818 (spec) 8573 (Lisp_Object spec)
8819 Lisp_Object spec;
8820{ 8574{
8821 int id = -1; 8575 int id = -1;
8822 8576
@@ -8848,11 +8602,10 @@ DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 2, 2, 0,
8848 doc: /* Initialize image library implementing image type TYPE. 8602 doc: /* Initialize image library implementing image type TYPE.
8849 Return non-nil if TYPE is a supported image type. 8603 Return non-nil if TYPE is a supported image type.
8850 8604
8851 Image types pbm and xbm are prebuilt; other types are loaded here. 8605Image types pbm and xbm are prebuilt; other types are loaded here.
8852 Libraries to load are specified in alist LIBRARIES (usually, the value 8606Libraries to load are specified in alist LIBRARIES (usually, the value
8853 of `image-library-alist', which see). */) 8607of `image-library-alist', which see). */)
8854 (type, libraries) 8608 (Lisp_Object type, Lisp_Object libraries)
8855 Lisp_Object type, libraries;
8856{ 8609{
8857 Lisp_Object tested; 8610 Lisp_Object tested;
8858 8611
@@ -8912,10 +8665,8 @@ DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 2, 2, 0,
8912 8665
8913 8666
8914void 8667void
8915syms_of_image () 8668syms_of_image (void)
8916{ 8669{
8917 extern Lisp_Object Qrisky_local_variable; /* Syms_of_xdisp has already run. */
8918
8919 /* Initialize this only once, since that's what we do with Vimage_types 8670 /* Initialize this only once, since that's what we do with Vimage_types
8920 and they are supposed to be in sync. Initializing here gives correct 8671 and they are supposed to be in sync. Initializing here gives correct
8921 operation on GNU/Linux of calling dump-emacs after loading some images. */ 8672 operation on GNU/Linux of calling dump-emacs after loading some images. */
@@ -9118,7 +8869,7 @@ listed; they are always supported. */);
9118 8869
9119 8870
9120void 8871void
9121init_image () 8872init_image (void)
9122{ 8873{
9123 8874
9124} 8875}