aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorStefan Monnier2010-10-15 17:55:33 -0400
committerStefan Monnier2010-10-15 17:55:33 -0400
commit0c747cb143fa227e78f350ac353d703f489209df (patch)
tree5b434055c797bd75eaa1e3d9d0773e586d44daee /src/image.c
parenta01a7932080e8a6e7bc8472c58cefabcc2c37df3 (diff)
parentaa095b2db98ae149737f8de00ee733b1d257ed33 (diff)
downloademacs-0c747cb143fa227e78f350ac353d703f489209df.tar.gz
emacs-0c747cb143fa227e78f350ac353d703f489209df.zip
Merge from trunk
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c143
1 files changed, 68 insertions, 75 deletions
diff --git a/src/image.c b/src/image.c
index 3c74c516d3f..4cdd7f2bbab 100644
--- a/src/image.c
+++ b/src/image.c
@@ -567,10 +567,6 @@ static struct image_type *image_types;
567 567
568Lisp_Object Vimage_types; 568Lisp_Object Vimage_types;
569 569
570/* An alist of image types and libraries that implement the type. */
571
572Lisp_Object Vimage_library_alist;
573
574/* Cache for delayed-loading image types. */ 570/* Cache for delayed-loading image types. */
575 571
576static Lisp_Object Vimage_type_cache; 572static Lisp_Object Vimage_type_cache;
@@ -645,7 +641,7 @@ lookup_image_type (Lisp_Object symbol)
645 struct image_type *type; 641 struct image_type *type;
646 642
647 /* We must initialize the image-type if it hasn't been already. */ 643 /* We must initialize the image-type if it hasn't been already. */
648 if (NILP (Finit_image_library (symbol, Vimage_library_alist))) 644 if (NILP (Finit_image_library (symbol, Vdynamic_library_alist)))
649 return 0; /* unimplemented */ 645 return 0; /* unimplemented */
650 646
651 for (type = image_types; type; type = type->next) 647 for (type = image_types; type; type = type->next)
@@ -1914,7 +1910,7 @@ mark_image_cache (struct image_cache *c)
1914#ifdef HAVE_NTGUI 1910#ifdef HAVE_NTGUI
1915 1911
1916/* Macro for defining functions that will be loaded from image DLLs. */ 1912/* Macro for defining functions that will be loaded from image DLLs. */
1917#define DEF_IMGLIB_FN(func) int (FAR CDECL *fn_##func)() 1913#define DEF_IMGLIB_FN(func,args) int (FAR CDECL *fn_##func)args
1918 1914
1919/* Macro for loading those image functions from the library. */ 1915/* Macro for loading those image functions from the library. */
1920#define LOAD_IMGLIB_FN(lib,func) { \ 1916#define LOAD_IMGLIB_FN(lib,func) { \
@@ -1923,10 +1919,11 @@ mark_image_cache (struct image_cache *c)
1923 } 1919 }
1924 1920
1925/* Load a DLL implementing an image type. 1921/* Load a DLL implementing an image type.
1926 The `image-library-alist' variable associates a symbol, 1922 The argument LIBRARIES is usually the variable
1927 identifying an image type, to a list of possible filenames. 1923 `dynamic-library-alist', which associates a symbol, identifying
1924 an external DLL library, to a list of possible filenames.
1928 The function returns NULL if no library could be loaded for 1925 The function returns NULL if no library could be loaded for
1929 the given image type, or if the library was previously loaded; 1926 the given symbol, or if the library was previously loaded;
1930 else the handle of the DLL. */ 1927 else the handle of the DLL. */
1931static HMODULE 1928static HMODULE
1932w32_delayed_load (Lisp_Object libraries, Lisp_Object type) 1929w32_delayed_load (Lisp_Object libraries, Lisp_Object type)
@@ -3268,10 +3265,12 @@ xpm_free_colors (Display *dpy, Colormap cmap, Pixel *pixels, int npixels, void *
3268 3265
3269/* XPM library details. */ 3266/* XPM library details. */
3270 3267
3271DEF_IMGLIB_FN (XpmFreeAttributes); 3268DEF_IMGLIB_FN (XpmFreeAttributes, (XpmAttributes *));
3272DEF_IMGLIB_FN (XpmCreateImageFromBuffer); 3269DEF_IMGLIB_FN (XpmCreateImageFromBuffer, (Display *, char *, xpm_XImage **,
3273DEF_IMGLIB_FN (XpmReadFileToImage); 3270 xpm_XImage **, XpmAttributes *));
3274DEF_IMGLIB_FN (XImageFree); 3271DEF_IMGLIB_FN (XpmReadFileToImage, (Display *, char *, xpm_XImage **,
3272 xpm_XImage **, XpmAttributes *));
3273DEF_IMGLIB_FN (XImageFree, (xpm_XImage *));
3275 3274
3276static int 3275static int
3277init_xpm_functions (Lisp_Object libraries) 3276init_xpm_functions (Lisp_Object libraries)
@@ -5439,27 +5438,31 @@ png_image_p (Lisp_Object object)
5439#ifdef HAVE_NTGUI 5438#ifdef HAVE_NTGUI
5440/* PNG library details. */ 5439/* PNG library details. */
5441 5440
5442DEF_IMGLIB_FN (png_get_io_ptr); 5441DEF_IMGLIB_FN (png_get_io_ptr, (png_structp));
5443DEF_IMGLIB_FN (png_sig_cmp); 5442DEF_IMGLIB_FN (png_sig_cmp, (png_bytep, png_size_t, png_size_t));
5444DEF_IMGLIB_FN (png_create_read_struct); 5443DEF_IMGLIB_FN (png_create_read_struct, (png_const_charp, png_voidp,
5445DEF_IMGLIB_FN (png_create_info_struct); 5444 png_error_ptr, png_error_ptr));
5446DEF_IMGLIB_FN (png_destroy_read_struct); 5445DEF_IMGLIB_FN (png_create_info_struct, (png_structp));
5447DEF_IMGLIB_FN (png_set_read_fn); 5446DEF_IMGLIB_FN (png_destroy_read_struct, (png_structpp, png_infopp, png_infopp));
5448DEF_IMGLIB_FN (png_set_sig_bytes); 5447DEF_IMGLIB_FN (png_set_read_fn, (png_structp, png_voidp, png_rw_ptr));
5449DEF_IMGLIB_FN (png_read_info); 5448DEF_IMGLIB_FN (png_set_sig_bytes, (png_structp, int));
5450DEF_IMGLIB_FN (png_get_IHDR); 5449DEF_IMGLIB_FN (png_read_info, (png_structp, png_infop));
5451DEF_IMGLIB_FN (png_get_valid); 5450DEF_IMGLIB_FN (png_get_IHDR, (png_structp, png_infop,
5452DEF_IMGLIB_FN (png_set_strip_16); 5451 png_uint_32 *, png_uint_32 *,
5453DEF_IMGLIB_FN (png_set_expand); 5452 int *, int *, int *, int *, int *));
5454DEF_IMGLIB_FN (png_set_gray_to_rgb); 5453DEF_IMGLIB_FN (png_get_valid, (png_structp, png_infop, png_uint_32));
5455DEF_IMGLIB_FN (png_set_background); 5454DEF_IMGLIB_FN (png_set_strip_16, (png_structp));
5456DEF_IMGLIB_FN (png_get_bKGD); 5455DEF_IMGLIB_FN (png_set_expand, (png_structp));
5457DEF_IMGLIB_FN (png_read_update_info); 5456DEF_IMGLIB_FN (png_set_gray_to_rgb, (png_structp));
5458DEF_IMGLIB_FN (png_get_channels); 5457DEF_IMGLIB_FN (png_set_background, (png_structp, png_color_16p,
5459DEF_IMGLIB_FN (png_get_rowbytes); 5458 int, int, double));
5460DEF_IMGLIB_FN (png_read_image); 5459DEF_IMGLIB_FN (png_get_bKGD, (png_structp, png_infop, png_color_16p *));
5461DEF_IMGLIB_FN (png_read_end); 5460DEF_IMGLIB_FN (png_read_update_info, (png_structp, png_infop));
5462DEF_IMGLIB_FN (png_error); 5461DEF_IMGLIB_FN (png_get_channels, (png_structp, png_infop));
5462DEF_IMGLIB_FN (png_get_rowbytes, (png_structp, png_infop));
5463DEF_IMGLIB_FN (png_read_image, (png_structp, png_bytepp));
5464DEF_IMGLIB_FN (png_read_end, (png_structp, png_infop));
5465DEF_IMGLIB_FN (png_error, (png_structp, png_const_charp));
5463 5466
5464static int 5467static int
5465init_png_functions (Lisp_Object libraries) 5468init_png_functions (Lisp_Object libraries)
@@ -6042,14 +6045,14 @@ jpeg_image_p (Lisp_Object object)
6042#ifdef HAVE_NTGUI 6045#ifdef HAVE_NTGUI
6043 6046
6044/* JPEG library details. */ 6047/* JPEG library details. */
6045DEF_IMGLIB_FN (jpeg_CreateDecompress); 6048DEF_IMGLIB_FN (jpeg_CreateDecompress, (j_decompress_ptr, int, size_t));
6046DEF_IMGLIB_FN (jpeg_start_decompress); 6049DEF_IMGLIB_FN (jpeg_start_decompress, (j_decompress_ptr));
6047DEF_IMGLIB_FN (jpeg_finish_decompress); 6050DEF_IMGLIB_FN (jpeg_finish_decompress, (j_decompress_ptr));
6048DEF_IMGLIB_FN (jpeg_destroy_decompress); 6051DEF_IMGLIB_FN (jpeg_destroy_decompress, (j_decompress_ptr));
6049DEF_IMGLIB_FN (jpeg_read_header); 6052DEF_IMGLIB_FN (jpeg_read_header, (j_decompress_ptr, boolean));
6050DEF_IMGLIB_FN (jpeg_read_scanlines); 6053DEF_IMGLIB_FN (jpeg_read_scanlines, (j_decompress_ptr, JSAMPARRAY, JDIMENSION));
6051DEF_IMGLIB_FN (jpeg_std_error); 6054DEF_IMGLIB_FN (jpeg_std_error, (struct jpeg_error_mgr *));
6052DEF_IMGLIB_FN (jpeg_resync_to_restart); 6055DEF_IMGLIB_FN (jpeg_resync_to_restart, (j_decompress_ptr, int));
6053 6056
6054static int 6057static int
6055init_jpeg_functions (Lisp_Object libraries) 6058init_jpeg_functions (Lisp_Object libraries)
@@ -6575,14 +6578,17 @@ tiff_image_p (Lisp_Object object)
6575#ifdef HAVE_NTGUI 6578#ifdef HAVE_NTGUI
6576 6579
6577/* TIFF library details. */ 6580/* TIFF library details. */
6578DEF_IMGLIB_FN (TIFFSetErrorHandler); 6581DEF_IMGLIB_FN (TIFFSetErrorHandler, (TIFFErrorHandler));
6579DEF_IMGLIB_FN (TIFFSetWarningHandler); 6582DEF_IMGLIB_FN (TIFFSetWarningHandler, (TIFFErrorHandler));
6580DEF_IMGLIB_FN (TIFFOpen); 6583DEF_IMGLIB_FN (TIFFOpen, (const char *, const char *));
6581DEF_IMGLIB_FN (TIFFClientOpen); 6584DEF_IMGLIB_FN (TIFFClientOpen, (const char *, const char *, thandle_t,
6582DEF_IMGLIB_FN (TIFFGetField); 6585 TIFFReadWriteProc, TIFFReadWriteProc,
6583DEF_IMGLIB_FN (TIFFReadRGBAImage); 6586 TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
6584DEF_IMGLIB_FN (TIFFClose); 6587 TIFFMapFileProc, TIFFUnmapFileProc));
6585DEF_IMGLIB_FN (TIFFSetDirectory); 6588DEF_IMGLIB_FN (TIFFGetField, (TIFF *, ttag_t, ...));
6589DEF_IMGLIB_FN (TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int));
6590DEF_IMGLIB_FN (TIFFClose, (TIFF *));
6591DEF_IMGLIB_FN (TIFFSetDirectory, (TIFF *, tdir_t));
6586 6592
6587static int 6593static int
6588init_tiff_functions (Lisp_Object libraries) 6594init_tiff_functions (Lisp_Object libraries)
@@ -6787,8 +6793,9 @@ tiff_load (struct frame *f, struct image *img)
6787 memsrc.len = SBYTES (specified_data); 6793 memsrc.len = SBYTES (specified_data);
6788 memsrc.index = 0; 6794 memsrc.index = 0;
6789 6795
6790 /* Casting return value avoids a GCC warning on W32. */ 6796 /* Casting arguments return value avoids a GCC warning on W32. */
6791 tiff = (TIFF *)fn_TIFFClientOpen ("memory_source", "r", &memsrc, 6797 tiff = (TIFF *)fn_TIFFClientOpen ("memory_source", "r",
6798 (thandle_t) &memsrc,
6792 (TIFFReadWriteProc) tiff_read_from_memory, 6799 (TIFFReadWriteProc) tiff_read_from_memory,
6793 (TIFFReadWriteProc) tiff_write_from_memory, 6800 (TIFFReadWriteProc) tiff_write_from_memory,
6794 tiff_seek_in_memory, 6801 tiff_seek_in_memory,
@@ -7024,10 +7031,10 @@ gif_image_p (Lisp_Object object)
7024#ifdef HAVE_NTGUI 7031#ifdef HAVE_NTGUI
7025 7032
7026/* GIF library details. */ 7033/* GIF library details. */
7027DEF_IMGLIB_FN (DGifCloseFile); 7034DEF_IMGLIB_FN (DGifCloseFile, (GifFileType *));
7028DEF_IMGLIB_FN (DGifSlurp); 7035DEF_IMGLIB_FN (DGifSlurp, (GifFileType *));
7029DEF_IMGLIB_FN (DGifOpen); 7036DEF_IMGLIB_FN (DGifOpen, (void *, InputFunc));
7030DEF_IMGLIB_FN (DGifOpenFileName); 7037DEF_IMGLIB_FN (DGifOpenFileName, (const char *));
7031 7038
7032static int 7039static int
7033init_gif_functions (Lisp_Object libraries) 7040init_gif_functions (Lisp_Object libraries)
@@ -8583,7 +8590,7 @@ Return non-nil if TYPE is a supported image type.
8583 8590
8584Image types pbm and xbm are prebuilt; other types are loaded here. 8591Image types pbm and xbm are prebuilt; other types are loaded here.
8585Libraries to load are specified in alist LIBRARIES (usually, the value 8592Libraries to load are specified in alist LIBRARIES (usually, the value
8586of `image-library-alist', which see). */) 8593of `dynamic-library-alist', which see). */)
8587 (Lisp_Object type, Lisp_Object libraries) 8594 (Lisp_Object type, Lisp_Object libraries)
8588{ 8595{
8589 Lisp_Object tested; 8596 Lisp_Object tested;
@@ -8659,20 +8666,6 @@ Each element of the list is a symbol for an image type, like 'jpeg or 'png.
8659To check whether it is really supported, use `image-type-available-p'. */); 8666To check whether it is really supported, use `image-type-available-p'. */);
8660 Vimage_types = Qnil; 8667 Vimage_types = Qnil;
8661 8668
8662 DEFVAR_LISP ("image-library-alist", &Vimage_library_alist,
8663 doc: /* Alist of image types vs external libraries needed to display them.
8664
8665Each element is a list (IMAGE-TYPE LIBRARY...), where the car is a symbol
8666representing a supported image type, and the rest are strings giving
8667alternate filenames for the corresponding external libraries.
8668
8669Emacs tries to load the libraries in the order they appear on the
8670list; if none is loaded, the running session of Emacs won't
8671support the image type. Types 'pbm and 'xbm don't need to be
8672listed; they are always supported. */);
8673 Vimage_library_alist = Qnil;
8674 Fput (intern_c_string ("image-library-alist"), Qrisky_local_variable, Qt);
8675
8676 DEFVAR_LISP ("max-image-size", &Vmax_image_size, 8669 DEFVAR_LISP ("max-image-size", &Vmax_image_size,
8677 doc: /* Maximum size of images. 8670 doc: /* Maximum size of images.
8678Emacs will not load an image into memory if its pixel width or 8671Emacs will not load an image into memory if its pixel width or
@@ -8718,11 +8711,11 @@ non-numeric, there is no explicit limit on the size of images. */);
8718 staticpro (&QCheuristic_mask); 8711 staticpro (&QCheuristic_mask);
8719 QCindex = intern_c_string (":index"); 8712 QCindex = intern_c_string (":index");
8720 staticpro (&QCindex); 8713 staticpro (&QCindex);
8721 QCgeometry = intern (":geometry"); 8714 QCgeometry = intern_c_string (":geometry");
8722 staticpro (&QCgeometry); 8715 staticpro (&QCgeometry);
8723 QCcrop = intern (":crop"); 8716 QCcrop = intern_c_string (":crop");
8724 staticpro (&QCcrop); 8717 staticpro (&QCcrop);
8725 QCrotation = intern (":rotation"); 8718 QCrotation = intern_c_string (":rotation");
8726 staticpro (&QCrotation); 8719 staticpro (&QCrotation);
8727 QCmatrix = intern_c_string (":matrix"); 8720 QCmatrix = intern_c_string (":matrix");
8728 staticpro (&QCmatrix); 8721 staticpro (&QCmatrix);
@@ -8785,7 +8778,7 @@ non-numeric, there is no explicit limit on the size of images. */);
8785#endif 8778#endif
8786 8779
8787#if defined (HAVE_IMAGEMAGICK) 8780#if defined (HAVE_IMAGEMAGICK)
8788 Qimagemagick = intern ("imagemagick"); 8781 Qimagemagick = intern_c_string ("imagemagick");
8789 staticpro (&Qimagemagick); 8782 staticpro (&Qimagemagick);
8790 ADD_IMAGE_TYPE (Qimagemagick); 8783 ADD_IMAGE_TYPE (Qimagemagick);
8791#endif 8784#endif