diff options
| author | Juanma Barranquero | 2003-01-31 07:20:13 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2003-01-31 07:20:13 +0000 |
| commit | 1ffb278b0dbe207495f5b2fc08fb5cf4f1bc0fb2 (patch) | |
| tree | a33b3452736289e73af59113e35de967cb1e068b | |
| parent | 6b89e3aa2801c5be6b42d8a1ac8337f355ed216c (diff) | |
| download | emacs-1ffb278b0dbe207495f5b2fc08fb5cf4f1bc0fb2.tar.gz emacs-1ffb278b0dbe207495f5b2fc08fb5cf4f1bc0fb2.zip | |
(DrawText): Kludge to avoid a redefinition on Windows when including gif_lib.h.
(init_gif_functions): New function.
(gif_load): Sync with xfns.c version. Adjust colors for Windows. Disable color
table lookups. Call gif library functions through pointers determined at
runtime.
(init_external_image_libraries): Try to load libungif.dll.
| -rw-r--r-- | src/w32fns.c | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 7d8044085b9..a1072ca7bbb 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -12919,7 +12919,9 @@ tiff_load (f, img) | |||
| 12919 | 12919 | ||
| 12920 | #if HAVE_GIF | 12920 | #if HAVE_GIF |
| 12921 | 12921 | ||
| 12922 | #define DrawText gif_DrawText | ||
| 12922 | #include <gif_lib.h> | 12923 | #include <gif_lib.h> |
| 12924 | #undef DrawText | ||
| 12923 | 12925 | ||
| 12924 | static int gif_image_p P_ ((Lisp_Object object)); | 12926 | static int gif_image_p P_ ((Lisp_Object object)); |
| 12925 | static int gif_load P_ ((struct frame *f, struct image *img)); | 12927 | static int gif_load P_ ((struct frame *f, struct image *img)); |
| @@ -12975,6 +12977,25 @@ static struct image_type gif_type = | |||
| 12975 | NULL | 12977 | NULL |
| 12976 | }; | 12978 | }; |
| 12977 | 12979 | ||
| 12980 | |||
| 12981 | /* GIF library details. */ | ||
| 12982 | DEF_IMGLIB_FN (DGifCloseFile); | ||
| 12983 | DEF_IMGLIB_FN (DGifSlurp); | ||
| 12984 | DEF_IMGLIB_FN (DGifOpen); | ||
| 12985 | DEF_IMGLIB_FN (DGifOpenFileName); | ||
| 12986 | |||
| 12987 | static int | ||
| 12988 | init_gif_functions (library) | ||
| 12989 | HMODULE library; | ||
| 12990 | { | ||
| 12991 | LOAD_IMGLIB_FN (library, DGifCloseFile); | ||
| 12992 | LOAD_IMGLIB_FN (library, DGifSlurp); | ||
| 12993 | LOAD_IMGLIB_FN (library, DGifOpen); | ||
| 12994 | LOAD_IMGLIB_FN (library, DGifOpenFileName); | ||
| 12995 | return 1; | ||
| 12996 | } | ||
| 12997 | |||
| 12998 | |||
| 12978 | /* Return non-zero if OBJECT is a valid GIF image specification. */ | 12999 | /* Return non-zero if OBJECT is a valid GIF image specification. */ |
| 12979 | 13000 | ||
| 12980 | static int | 13001 | static int |
| @@ -13061,7 +13082,7 @@ gif_load (f, img) | |||
| 13061 | } | 13082 | } |
| 13062 | 13083 | ||
| 13063 | /* Open the GIF file. */ | 13084 | /* Open the GIF file. */ |
| 13064 | gif = DGifOpenFileName (SDATA (file)); | 13085 | gif = fn_DGifOpenFileName (SDATA (file)); |
| 13065 | if (gif == NULL) | 13086 | if (gif == NULL) |
| 13066 | { | 13087 | { |
| 13067 | image_error ("Cannot open `%s'", file, Qnil); | 13088 | image_error ("Cannot open `%s'", file, Qnil); |
| @@ -13077,7 +13098,7 @@ gif_load (f, img) | |||
| 13077 | memsrc.len = SBYTES (specified_data); | 13098 | memsrc.len = SBYTES (specified_data); |
| 13078 | memsrc.index = 0; | 13099 | memsrc.index = 0; |
| 13079 | 13100 | ||
| 13080 | gif = DGifOpen(&memsrc, gif_read_from_memory); | 13101 | gif = fn_DGifOpen(&memsrc, gif_read_from_memory); |
| 13081 | if (!gif) | 13102 | if (!gif) |
| 13082 | { | 13103 | { |
| 13083 | image_error ("Cannot open memory source `%s'", img->spec, Qnil); | 13104 | image_error ("Cannot open memory source `%s'", img->spec, Qnil); |
| @@ -13087,11 +13108,11 @@ gif_load (f, img) | |||
| 13087 | } | 13108 | } |
| 13088 | 13109 | ||
| 13089 | /* Read entire contents. */ | 13110 | /* Read entire contents. */ |
| 13090 | rc = DGifSlurp (gif); | 13111 | rc = fn_DGifSlurp (gif); |
| 13091 | if (rc == GIF_ERROR) | 13112 | if (rc == GIF_ERROR) |
| 13092 | { | 13113 | { |
| 13093 | image_error ("Error reading `%s'", img->spec, Qnil); | 13114 | image_error ("Error reading `%s'", img->spec, Qnil); |
| 13094 | DGifCloseFile (gif); | 13115 | fn_DGifCloseFile (gif); |
| 13095 | UNGCPRO; | 13116 | UNGCPRO; |
| 13096 | return 0; | 13117 | return 0; |
| 13097 | } | 13118 | } |
| @@ -13102,18 +13123,18 @@ gif_load (f, img) | |||
| 13102 | { | 13123 | { |
| 13103 | image_error ("Invalid image number `%s' in image `%s'", | 13124 | image_error ("Invalid image number `%s' in image `%s'", |
| 13104 | image, img->spec); | 13125 | image, img->spec); |
| 13105 | DGifCloseFile (gif); | 13126 | fn_DGifCloseFile (gif); |
| 13106 | UNGCPRO; | 13127 | UNGCPRO; |
| 13107 | return 0; | 13128 | return 0; |
| 13108 | } | 13129 | } |
| 13109 | 13130 | ||
| 13110 | width = img->width = gif->SWidth; | 13131 | width = img->width = max (gif->SWidth, gif->Image.Left + gif->Image.Width); |
| 13111 | height = img->height = gif->SHeight; | 13132 | height = img->height = max (gif->SHeight, gif->Image.Top + gif->Image.Height); |
| 13112 | 13133 | ||
| 13113 | /* Create the X image and pixmap. */ | 13134 | /* Create the X image and pixmap. */ |
| 13114 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) | 13135 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) |
| 13115 | { | 13136 | { |
| 13116 | DGifCloseFile (gif); | 13137 | fn_DGifCloseFile (gif); |
| 13117 | UNGCPRO; | 13138 | UNGCPRO; |
| 13118 | return 0; | 13139 | return 0; |
| 13119 | } | 13140 | } |
| @@ -13122,19 +13143,27 @@ gif_load (f, img) | |||
| 13122 | gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap; | 13143 | gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap; |
| 13123 | if (!gif_color_map) | 13144 | if (!gif_color_map) |
| 13124 | gif_color_map = gif->SColorMap; | 13145 | gif_color_map = gif->SColorMap; |
| 13146 | #if 0 /* TODO: Color tables */ | ||
| 13125 | init_color_table (); | 13147 | init_color_table (); |
| 13148 | #endif | ||
| 13126 | bzero (pixel_colors, sizeof pixel_colors); | 13149 | bzero (pixel_colors, sizeof pixel_colors); |
| 13127 | 13150 | ||
| 13128 | for (i = 0; i < gif_color_map->ColorCount; ++i) | 13151 | for (i = 0; i < gif_color_map->ColorCount; ++i) |
| 13129 | { | 13152 | { |
| 13130 | int r = gif_color_map->Colors[i].Red << 8; | 13153 | int r = gif_color_map->Colors[i].Red; |
| 13131 | int g = gif_color_map->Colors[i].Green << 8; | 13154 | int g = gif_color_map->Colors[i].Green; |
| 13132 | int b = gif_color_map->Colors[i].Blue << 8; | 13155 | int b = gif_color_map->Colors[i].Blue; |
| 13156 | #if 0 /* TODO: Color tables */ | ||
| 13133 | pixel_colors[i] = lookup_rgb_color (f, r, g, b); | 13157 | pixel_colors[i] = lookup_rgb_color (f, r, g, b); |
| 13158 | #else | ||
| 13159 | pixel_colors[i] = PALETTERGB (r, g, b); | ||
| 13160 | #endif | ||
| 13134 | } | 13161 | } |
| 13135 | 13162 | ||
| 13163 | #if 0 /* TODO: Color tables */ | ||
| 13136 | img->colors = colors_in_color_table (&img->ncolors); | 13164 | img->colors = colors_in_color_table (&img->ncolors); |
| 13137 | free_color_table (); | 13165 | free_color_table (); |
| 13166 | #endif | ||
| 13138 | 13167 | ||
| 13139 | /* Clear the part of the screen image that are not covered by | 13168 | /* Clear the part of the screen image that are not covered by |
| 13140 | the image from the GIF file. Full animated GIF support | 13169 | the image from the GIF file. Full animated GIF support |
| @@ -13205,7 +13234,7 @@ gif_load (f, img) | |||
| 13205 | } | 13234 | } |
| 13206 | } | 13235 | } |
| 13207 | 13236 | ||
| 13208 | DGifCloseFile (gif); | 13237 | fn_DGifCloseFile (gif); |
| 13209 | 13238 | ||
| 13210 | /* Maybe fill in the background field while we have ximg handy. */ | 13239 | /* Maybe fill in the background field while we have ximg handy. */ |
| 13211 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | 13240 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) |
| @@ -15694,7 +15723,11 @@ init_external_image_libraries () | |||
| 15694 | #endif | 15723 | #endif |
| 15695 | 15724 | ||
| 15696 | #if HAVE_GIF | 15725 | #if HAVE_GIF |
| 15697 | define_image_type (&gif_type); | 15726 | if (library = LoadLibrary ("libungif.dll")) |
| 15727 | { | ||
| 15728 | if (init_gif_functions (library)) | ||
| 15729 | define_image_type (&gif_type); | ||
| 15730 | } | ||
| 15698 | #endif | 15731 | #endif |
| 15699 | 15732 | ||
| 15700 | #if HAVE_PNG | 15733 | #if HAVE_PNG |