diff options
| author | Stefan Monnier | 2010-10-15 17:55:33 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2010-10-15 17:55:33 -0400 |
| commit | 0c747cb143fa227e78f350ac353d703f489209df (patch) | |
| tree | 5b434055c797bd75eaa1e3d9d0773e586d44daee /src/image.c | |
| parent | a01a7932080e8a6e7bc8472c58cefabcc2c37df3 (diff) | |
| parent | aa095b2db98ae149737f8de00ee733b1d257ed33 (diff) | |
| download | emacs-0c747cb143fa227e78f350ac353d703f489209df.tar.gz emacs-0c747cb143fa227e78f350ac353d703f489209df.zip | |
Merge from trunk
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 143 |
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 | ||
| 568 | Lisp_Object Vimage_types; | 568 | Lisp_Object Vimage_types; |
| 569 | 569 | ||
| 570 | /* An alist of image types and libraries that implement the type. */ | ||
| 571 | |||
| 572 | Lisp_Object Vimage_library_alist; | ||
| 573 | |||
| 574 | /* Cache for delayed-loading image types. */ | 570 | /* Cache for delayed-loading image types. */ |
| 575 | 571 | ||
| 576 | static Lisp_Object Vimage_type_cache; | 572 | static 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. */ |
| 1931 | static HMODULE | 1928 | static HMODULE |
| 1932 | w32_delayed_load (Lisp_Object libraries, Lisp_Object type) | 1929 | w32_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 | ||
| 3271 | DEF_IMGLIB_FN (XpmFreeAttributes); | 3268 | DEF_IMGLIB_FN (XpmFreeAttributes, (XpmAttributes *)); |
| 3272 | DEF_IMGLIB_FN (XpmCreateImageFromBuffer); | 3269 | DEF_IMGLIB_FN (XpmCreateImageFromBuffer, (Display *, char *, xpm_XImage **, |
| 3273 | DEF_IMGLIB_FN (XpmReadFileToImage); | 3270 | xpm_XImage **, XpmAttributes *)); |
| 3274 | DEF_IMGLIB_FN (XImageFree); | 3271 | DEF_IMGLIB_FN (XpmReadFileToImage, (Display *, char *, xpm_XImage **, |
| 3272 | xpm_XImage **, XpmAttributes *)); | ||
| 3273 | DEF_IMGLIB_FN (XImageFree, (xpm_XImage *)); | ||
| 3275 | 3274 | ||
| 3276 | static int | 3275 | static int |
| 3277 | init_xpm_functions (Lisp_Object libraries) | 3276 | init_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 | ||
| 5442 | DEF_IMGLIB_FN (png_get_io_ptr); | 5441 | DEF_IMGLIB_FN (png_get_io_ptr, (png_structp)); |
| 5443 | DEF_IMGLIB_FN (png_sig_cmp); | 5442 | DEF_IMGLIB_FN (png_sig_cmp, (png_bytep, png_size_t, png_size_t)); |
| 5444 | DEF_IMGLIB_FN (png_create_read_struct); | 5443 | DEF_IMGLIB_FN (png_create_read_struct, (png_const_charp, png_voidp, |
| 5445 | DEF_IMGLIB_FN (png_create_info_struct); | 5444 | png_error_ptr, png_error_ptr)); |
| 5446 | DEF_IMGLIB_FN (png_destroy_read_struct); | 5445 | DEF_IMGLIB_FN (png_create_info_struct, (png_structp)); |
| 5447 | DEF_IMGLIB_FN (png_set_read_fn); | 5446 | DEF_IMGLIB_FN (png_destroy_read_struct, (png_structpp, png_infopp, png_infopp)); |
| 5448 | DEF_IMGLIB_FN (png_set_sig_bytes); | 5447 | DEF_IMGLIB_FN (png_set_read_fn, (png_structp, png_voidp, png_rw_ptr)); |
| 5449 | DEF_IMGLIB_FN (png_read_info); | 5448 | DEF_IMGLIB_FN (png_set_sig_bytes, (png_structp, int)); |
| 5450 | DEF_IMGLIB_FN (png_get_IHDR); | 5449 | DEF_IMGLIB_FN (png_read_info, (png_structp, png_infop)); |
| 5451 | DEF_IMGLIB_FN (png_get_valid); | 5450 | DEF_IMGLIB_FN (png_get_IHDR, (png_structp, png_infop, |
| 5452 | DEF_IMGLIB_FN (png_set_strip_16); | 5451 | png_uint_32 *, png_uint_32 *, |
| 5453 | DEF_IMGLIB_FN (png_set_expand); | 5452 | int *, int *, int *, int *, int *)); |
| 5454 | DEF_IMGLIB_FN (png_set_gray_to_rgb); | 5453 | DEF_IMGLIB_FN (png_get_valid, (png_structp, png_infop, png_uint_32)); |
| 5455 | DEF_IMGLIB_FN (png_set_background); | 5454 | DEF_IMGLIB_FN (png_set_strip_16, (png_structp)); |
| 5456 | DEF_IMGLIB_FN (png_get_bKGD); | 5455 | DEF_IMGLIB_FN (png_set_expand, (png_structp)); |
| 5457 | DEF_IMGLIB_FN (png_read_update_info); | 5456 | DEF_IMGLIB_FN (png_set_gray_to_rgb, (png_structp)); |
| 5458 | DEF_IMGLIB_FN (png_get_channels); | 5457 | DEF_IMGLIB_FN (png_set_background, (png_structp, png_color_16p, |
| 5459 | DEF_IMGLIB_FN (png_get_rowbytes); | 5458 | int, int, double)); |
| 5460 | DEF_IMGLIB_FN (png_read_image); | 5459 | DEF_IMGLIB_FN (png_get_bKGD, (png_structp, png_infop, png_color_16p *)); |
| 5461 | DEF_IMGLIB_FN (png_read_end); | 5460 | DEF_IMGLIB_FN (png_read_update_info, (png_structp, png_infop)); |
| 5462 | DEF_IMGLIB_FN (png_error); | 5461 | DEF_IMGLIB_FN (png_get_channels, (png_structp, png_infop)); |
| 5462 | DEF_IMGLIB_FN (png_get_rowbytes, (png_structp, png_infop)); | ||
| 5463 | DEF_IMGLIB_FN (png_read_image, (png_structp, png_bytepp)); | ||
| 5464 | DEF_IMGLIB_FN (png_read_end, (png_structp, png_infop)); | ||
| 5465 | DEF_IMGLIB_FN (png_error, (png_structp, png_const_charp)); | ||
| 5463 | 5466 | ||
| 5464 | static int | 5467 | static int |
| 5465 | init_png_functions (Lisp_Object libraries) | 5468 | init_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. */ |
| 6045 | DEF_IMGLIB_FN (jpeg_CreateDecompress); | 6048 | DEF_IMGLIB_FN (jpeg_CreateDecompress, (j_decompress_ptr, int, size_t)); |
| 6046 | DEF_IMGLIB_FN (jpeg_start_decompress); | 6049 | DEF_IMGLIB_FN (jpeg_start_decompress, (j_decompress_ptr)); |
| 6047 | DEF_IMGLIB_FN (jpeg_finish_decompress); | 6050 | DEF_IMGLIB_FN (jpeg_finish_decompress, (j_decompress_ptr)); |
| 6048 | DEF_IMGLIB_FN (jpeg_destroy_decompress); | 6051 | DEF_IMGLIB_FN (jpeg_destroy_decompress, (j_decompress_ptr)); |
| 6049 | DEF_IMGLIB_FN (jpeg_read_header); | 6052 | DEF_IMGLIB_FN (jpeg_read_header, (j_decompress_ptr, boolean)); |
| 6050 | DEF_IMGLIB_FN (jpeg_read_scanlines); | 6053 | DEF_IMGLIB_FN (jpeg_read_scanlines, (j_decompress_ptr, JSAMPARRAY, JDIMENSION)); |
| 6051 | DEF_IMGLIB_FN (jpeg_std_error); | 6054 | DEF_IMGLIB_FN (jpeg_std_error, (struct jpeg_error_mgr *)); |
| 6052 | DEF_IMGLIB_FN (jpeg_resync_to_restart); | 6055 | DEF_IMGLIB_FN (jpeg_resync_to_restart, (j_decompress_ptr, int)); |
| 6053 | 6056 | ||
| 6054 | static int | 6057 | static int |
| 6055 | init_jpeg_functions (Lisp_Object libraries) | 6058 | init_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. */ |
| 6578 | DEF_IMGLIB_FN (TIFFSetErrorHandler); | 6581 | DEF_IMGLIB_FN (TIFFSetErrorHandler, (TIFFErrorHandler)); |
| 6579 | DEF_IMGLIB_FN (TIFFSetWarningHandler); | 6582 | DEF_IMGLIB_FN (TIFFSetWarningHandler, (TIFFErrorHandler)); |
| 6580 | DEF_IMGLIB_FN (TIFFOpen); | 6583 | DEF_IMGLIB_FN (TIFFOpen, (const char *, const char *)); |
| 6581 | DEF_IMGLIB_FN (TIFFClientOpen); | 6584 | DEF_IMGLIB_FN (TIFFClientOpen, (const char *, const char *, thandle_t, |
| 6582 | DEF_IMGLIB_FN (TIFFGetField); | 6585 | TIFFReadWriteProc, TIFFReadWriteProc, |
| 6583 | DEF_IMGLIB_FN (TIFFReadRGBAImage); | 6586 | TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, |
| 6584 | DEF_IMGLIB_FN (TIFFClose); | 6587 | TIFFMapFileProc, TIFFUnmapFileProc)); |
| 6585 | DEF_IMGLIB_FN (TIFFSetDirectory); | 6588 | DEF_IMGLIB_FN (TIFFGetField, (TIFF *, ttag_t, ...)); |
| 6589 | DEF_IMGLIB_FN (TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int)); | ||
| 6590 | DEF_IMGLIB_FN (TIFFClose, (TIFF *)); | ||
| 6591 | DEF_IMGLIB_FN (TIFFSetDirectory, (TIFF *, tdir_t)); | ||
| 6586 | 6592 | ||
| 6587 | static int | 6593 | static int |
| 6588 | init_tiff_functions (Lisp_Object libraries) | 6594 | init_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. */ |
| 7027 | DEF_IMGLIB_FN (DGifCloseFile); | 7034 | DEF_IMGLIB_FN (DGifCloseFile, (GifFileType *)); |
| 7028 | DEF_IMGLIB_FN (DGifSlurp); | 7035 | DEF_IMGLIB_FN (DGifSlurp, (GifFileType *)); |
| 7029 | DEF_IMGLIB_FN (DGifOpen); | 7036 | DEF_IMGLIB_FN (DGifOpen, (void *, InputFunc)); |
| 7030 | DEF_IMGLIB_FN (DGifOpenFileName); | 7037 | DEF_IMGLIB_FN (DGifOpenFileName, (const char *)); |
| 7031 | 7038 | ||
| 7032 | static int | 7039 | static int |
| 7033 | init_gif_functions (Lisp_Object libraries) | 7040 | init_gif_functions (Lisp_Object libraries) |
| @@ -8583,7 +8590,7 @@ Return non-nil if TYPE is a supported image type. | |||
| 8583 | 8590 | ||
| 8584 | Image types pbm and xbm are prebuilt; other types are loaded here. | 8591 | Image types pbm and xbm are prebuilt; other types are loaded here. |
| 8585 | Libraries to load are specified in alist LIBRARIES (usually, the value | 8592 | Libraries to load are specified in alist LIBRARIES (usually, the value |
| 8586 | of `image-library-alist', which see). */) | 8593 | of `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. | |||
| 8659 | To check whether it is really supported, use `image-type-available-p'. */); | 8666 | To 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 | |||
| 8665 | Each element is a list (IMAGE-TYPE LIBRARY...), where the car is a symbol | ||
| 8666 | representing a supported image type, and the rest are strings giving | ||
| 8667 | alternate filenames for the corresponding external libraries. | ||
| 8668 | |||
| 8669 | Emacs tries to load the libraries in the order they appear on the | ||
| 8670 | list; if none is loaded, the running session of Emacs won't | ||
| 8671 | support the image type. Types 'pbm and 'xbm don't need to be | ||
| 8672 | listed; 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. |
| 8678 | Emacs will not load an image into memory if its pixel width or | 8671 | Emacs 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 |