From: Joakim Verona Date: Thu, 13 May 2010 13:13:52 +0000 (+0200) Subject: merge and fixes X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~45^2~511^2~53 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ce07fa9adcea121b5515f98e161e257d1210c9b0;p=emacs.git merge and fixes --- ce07fa9adcea121b5515f98e161e257d1210c9b0 diff --cc README.imagemagick index 3c760dd75ea,00000000000..9096fe2b2f8 mode 100644,000000..100644 --- a/README.imagemagick +++ b/README.imagemagick @@@ -1,51 -1,0 +1,60 @@@ +This is the imagemagick branch of Emacs. Imagemagick can now be used +to load many new image formats, and also do useful transforms like +scaling and rotation. + +This file will attempt to contain draft NEWS, Changelog and manual +entries for the new functionality. + ++You might need to regenerate the configure scripts: ++aclocal ++automake ++autoheader ++autoconf ++./configure --with-imagemagick ++ ++ ++ +TODO +- complete documentation drafts below +- test with more systems, only tested on Fedora 12 so far, and the +libmagick that ships it. +- fix inconsistencys with spelling of imagemagick in the src +- report number of images in image bundle types somehow +- probably add pdf to inhibited types +- inhibit types is defconst should probably be defcustom +- decide what to do with some uncommitted imagemagick support + functions for image size etc. + + +* NEWS entry +** ImageMagick support +It is now possible to use the Imagemagick library to load many new +image formats in Emacs. + +To enable, use the following configure option: +--with-imagemagick + +The new function (imagemagick-types) returns a list of image file +extensions that your installation of imagemagick supports. + - The function (imagemagic-register-types) will enable the imagemagick ++The function (imagemagick-register-types) will enable the imagemagick +support for the extensions in imagemagick-types minus the types listed +in imagemagick-types-inhibit. + +imagemagick-types-inhibit has the value '(C HTML HTM TXT) by default. +This means imagemagick will be used also to load jpeg files, if you +have both jpeg and imagemagick libraries linked. Add 'JPG to +imagemagick-types-inhibit if you do not want this. + +Images loaded with imagemagick will support a couple of new display +specifications: + +- scale +- rotation +- index + +* Changelog entry +nothing yet + +* Manual entry +nothing yet diff --cc configure index 2557e41c4bf,fc9096b6783..ae6f8266211 --- a/configure +++ b/configure @@@ -638,152 -638,184 +638,186 @@@ ac_includes_default=" ac_config_libobj_dir=src ac_header_list= ac_func_list= -ac_subst_vars='SHELL -PATH_SEPARATOR -PACKAGE_NAME -PACKAGE_TARNAME -PACKAGE_VERSION -PACKAGE_STRING -PACKAGE_BUGREPORT -exec_prefix -prefix -program_transform_name -bindir -sbindir -libexecdir -datarootdir -datadir -sysconfdir -sharedstatedir -localstatedir -includedir -oldincludedir -docdir -infodir -htmldir -dvidir -pdfdir -psdir -libdir -localedir -mandir -DEFS -ECHO_C -ECHO_N -ECHO_T -LIBS -build_alias -host_alias -target_alias -MAINT -build -build_cpu -build_vendor -build_os -host -host_cpu -host_vendor -host_os -CC -CFLAGS -LDFLAGS -CPPFLAGS -ac_ct_CC -EXEEXT -OBJEXT -CPP -GREP -EGREP -INSTALL_PROGRAM -INSTALL_SCRIPT -INSTALL_DATA -RANLIB -INSTALL_INFO -GZIP_PROG -MAKEINFO -LD_SWITCH_SYSTEM -C_SWITCH_MACHINE -C_SWITCH_SYSTEM -LIBS_SYSTEM -CRT_DIR -LIB_MATH -START_FILES -LIBSOUND -PKG_CONFIG -ALSA_CFLAGS -ALSA_LIBS -CFLAGS_SOUND -SET_MAKE -XMKMF -LD_SWITCH_X_SITE_AUX -LD_SWITCH_X_SITE_AUX_RPATH -NS_OBJ -NS_SUPPORT -LIB_STANDARD -HAVE_XSERVER -RSVG_CFLAGS -RSVG_LIBS -GTK_CFLAGS -GTK_LIBS -GTK_OBJ -DBUS_CFLAGS -DBUS_LIBS -DBUS_OBJ -GCONF_CFLAGS -GCONF_LIBS -LIBSELINUX_LIBS -LIBXTR6 -LIBXMU -FONTCONFIG_CFLAGS -FONTCONFIG_LIBS -XFT_CFLAGS -XFT_LIBS -LIBOTF_CFLAGS -LIBOTF_LIBS -M17N_FLT_CFLAGS -M17N_FLT_LIBS -FONT_OBJ -FREETYPE_CFLAGS -FREETYPE_LIBS -LIBXPM -LIBJPEG -LIBPNG -LIBTIFF -LIBGIF -LIBGPM -GPM_MOUSE_SUPPORT -LIBXSM -ALLOCA -liblockfile -LIBS_MAIL -BLESSMAIL_TARGET -LIBOBJS -NEED_SETGID -KMEM_GROUP -GETLOADAVG_LIBS -GETOPT_H -GETOPTOBJS -LIBS_TERMCAP -TERMCAP_OBJ -LIBHESIOD -LIBRESOLV -COM_ERRLIB -CRYPTOLIB -KRB5LIB -DESLIB -KRB4LIB -version -configuration -canonical -srcdir -lispdir -locallisppath -lisppath -x_default_search_path -etcdir -archlibdir -bitmapdir -gamedir -gameuser -unexec -LD_SWITCH_X_SITE -C_SWITCH_X_SITE -C_SWITCH_X_SYSTEM -X_TOOLKIT_TYPE -machfile -opsysfile -ns_appdir -ns_appbindir -ns_appresdir -ns_appsrc -GNUSTEP_MAKEFILES -GNUSTEP_SYSTEM_HEADERS -GNUSTEP_SYSTEM_LIBRARIES -GNU_OBJC_CFLAGS -OTHER_FILES -XMENU_OBJ -XOBJ -WIDGET_OBJ -TOOLKIT_LIBW -LIBXT_OTHER -OLDXMENU -LIBXMENU -LIBX_OTHER -CYGWIN_OBJ -PRE_ALLOC_OBJ -POST_ALLOC_OBJ -LD_SWITCH_SYSTEM_TEMACS -LD_SWITCH_SYSTEM_EXTRA +ac_subst_vars='LTLIBOBJS + LIB_GCC -LTLIBOBJS' ++LD_SWITCH_SYSTEM_EXTRA ++LD_SWITCH_SYSTEM_TEMACS ++POST_ALLOC_OBJ ++PRE_ALLOC_OBJ ++CYGWIN_OBJ ++LIBX_OTHER ++LIBXMENU ++OLDXMENU ++LIBXT_OTHER ++TOOLKIT_LIBW ++WIDGET_OBJ ++XOBJ ++XMENU_OBJ +OTHER_FILES - LIB_SRC_EXTRA_INSTALLABLES +GNU_OBJC_CFLAGS +GNUSTEP_SYSTEM_LIBRARIES +GNUSTEP_SYSTEM_HEADERS +GNUSTEP_MAKEFILES +ns_appsrc +ns_appresdir +ns_appbindir +ns_appdir +opsysfile +machfile +X_TOOLKIT_TYPE ++C_SWITCH_X_SYSTEM +C_SWITCH_X_SITE - LD_SWITCH_X_SITE_AUX +LD_SWITCH_X_SITE - c_switch_machine - c_switch_system ++unexec +gameuser +gamedir +bitmapdir +archlibdir +etcdir +x_default_search_path +lisppath +locallisppath +lispdir +srcdir +canonical +configuration +version +KRB4LIB +DESLIB +KRB5LIB +CRYPTOLIB +COM_ERRLIB +LIBRESOLV +LIBHESIOD ++TERMCAP_OBJ ++LIBS_TERMCAP +GETOPTOBJS +GETOPT_H +GETLOADAVG_LIBS +KMEM_GROUP +NEED_SETGID +LIBOBJS ++BLESSMAIL_TARGET +LIBS_MAIL +liblockfile +ALLOCA ++LIBXSM ++GPM_MOUSE_SUPPORT +LIBGPM +LIBGIF +LIBTIFF +LIBPNG +LIBJPEG +LIBXPM +FREETYPE_LIBS +FREETYPE_CFLAGS ++FONT_OBJ +M17N_FLT_LIBS +M17N_FLT_CFLAGS +LIBOTF_LIBS +LIBOTF_CFLAGS +XFT_LIBS +XFT_CFLAGS +FONTCONFIG_LIBS +FONTCONFIG_CFLAGS ++LIBXMU ++LIBXTR6 ++LIBSELINUX_LIBS +GCONF_LIBS +GCONF_CFLAGS ++DBUS_OBJ +DBUS_LIBS +DBUS_CFLAGS ++GTK_OBJ +GTK_LIBS +GTK_CFLAGS +IMAGEMAGICK_LIBS +IMAGEMAGICK_CFLAGS +RSVG_LIBS +RSVG_CFLAGS +HAVE_XSERVER ++LIB_STANDARD ++NS_SUPPORT ++NS_OBJ ++LD_SWITCH_X_SITE_AUX_RPATH ++LD_SWITCH_X_SITE_AUX +XMKMF +SET_MAKE +CFLAGS_SOUND +ALSA_LIBS +ALSA_CFLAGS +PKG_CONFIG +LIBSOUND ++START_FILES ++LIB_MATH ++CRT_DIR ++LIBS_SYSTEM ++C_SWITCH_SYSTEM ++C_SWITCH_MACHINE ++LD_SWITCH_SYSTEM +MAKEINFO +GZIP_PROG +INSTALL_INFO +RANLIB +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM - LN_S +EGREP +GREP +CPP +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +MAINT +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking @@@ -11483,122 -11758,7 +11783,120 @@@ _ACEO fi fi +HAVE_IMAGEMAGICK=no - if test "${HAVE_X11}" = "yes" ; then - if test "${with_imagemagick}" != "no"; then - IMAGEMAGICK_REQUIRED=1 - IMAGEMAGICK_MODULE="MagickWand >= $IMAGEMAGICK_REQUIRED" - ++if test "${with_imagemagick}" != "no"; then ++ IMAGEMAGICK_REQUIRED=1 ++ IMAGEMAGICK_MODULE="MagickWand >= $IMAGEMAGICK_REQUIRED" + + succeeded=no + + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no" + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + if test "$PKG_CONFIG" = "no" ; then + : + else + PKG_CONFIG_MIN_VERSION=0.9.0 + if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then + { $as_echo "$as_me:$LINENO: checking for $IMAGEMAGICK_MODULE" >&5 +$as_echo_n "checking for $IMAGEMAGICK_MODULE... " >&6; } + + if $PKG_CONFIG --exists "$IMAGEMAGICK_MODULE" 2>&5; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + succeeded=yes + + { $as_echo "$as_me:$LINENO: checking IMAGEMAGICK_CFLAGS" >&5 +$as_echo_n "checking IMAGEMAGICK_CFLAGS... " >&6; } + IMAGEMAGICK_CFLAGS=`$PKG_CONFIG --cflags "$IMAGEMAGICK_MODULE"|sed -e 's,///*,/,g'` + { $as_echo "$as_me:$LINENO: result: $IMAGEMAGICK_CFLAGS" >&5 +$as_echo "$IMAGEMAGICK_CFLAGS" >&6; } + + { $as_echo "$as_me:$LINENO: checking IMAGEMAGICK_LIBS" >&5 +$as_echo_n "checking IMAGEMAGICK_LIBS... " >&6; } + IMAGEMAGICK_LIBS=`$PKG_CONFIG --libs "$IMAGEMAGICK_MODULE"|sed -e 's,///*,/,g'` + { $as_echo "$as_me:$LINENO: result: $IMAGEMAGICK_LIBS" >&5 +$as_echo "$IMAGEMAGICK_LIBS" >&6; } + else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + IMAGEMAGICK_CFLAGS="" + IMAGEMAGICK_LIBS="" + ## If we have a custom action on failure, don't print errors, but + ## do set a variable so people can do so. + IMAGEMAGICK_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$IMAGEMAGICK_MODULE"` + + fi + + + + else + echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." + echo "*** See http://www.freedesktop.org/software/pkgconfig" + fi + fi + + if test $succeeded = yes; then + : + else + : + fi + + + + - if test ".${IMAGEMAGICK_CFLAGS}" != "."; then - HAVE_IMAGEMAGICK=yes ++ if test ".${IMAGEMAGICK_CFLAGS}" != "."; then ++ HAVE_IMAGEMAGICK=yes + +cat >>confdefs.h <<\_ACEOF +#define HAVE_IMAGEMAGICK 1 +_ACEOF + - CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS" - LIBS="$IMAGEMAGICK_LIBS $LIBS" - fi ++ CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS" ++ LIBS="$IMAGEMAGICK_LIBS $LIBS" + fi +fi + + HAVE_GTK=no if test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then GLIB_REQUIRED=2.6 @@@ -12854,7 -13014,93 +13158,93 @@@ _ACEO fi fi + HAVE_LIBSELINUX=no + LIBSELINUX_LIBS= + if test "${with_selinux}" = "yes"; then + { $as_echo "$as_me:$LINENO: checking for lgetfilecon in -lselinux" >&5 + $as_echo_n "checking for lgetfilecon in -lselinux... " >&6; } + if test "${ac_cv_lib_selinux_lgetfilecon+set}" = set; then + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS + LIBS="-lselinux $LIBS" + cat >conftest.$ac_ext <<_ACEOF + /* confdefs.h. */ + _ACEOF + cat confdefs.h >>conftest.$ac_ext + cat >>conftest.$ac_ext <<_ACEOF + /* end confdefs.h. */ + + /* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ + #ifdef __cplusplus + extern "C" + #endif + char lgetfilecon (); + int + main () + { + return lgetfilecon (); + ; + return 0; + } + _ACEOF + rm -f conftest.$ac_objext conftest$ac_exeext + if { (ac_try="$ac_link" + case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; + esac + eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" + $as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_selinux_lgetfilecon=yes + else + $as_echo "$as_me: failed program was:" >&5 + sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_selinux_lgetfilecon=no + fi + + rm -rf conftest.dSYM + rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$ac_check_lib_save_LIBS + fi + { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_selinux_lgetfilecon" >&5 + $as_echo "$ac_cv_lib_selinux_lgetfilecon" >&6; } -if test $ac_cv_lib_selinux_lgetfilecon = yes; then ++if test "x$ac_cv_lib_selinux_lgetfilecon" = x""yes; then + HAVE_LIBSELINUX=yes + else + HAVE_LIBSELINUX=no + fi + + if test "$HAVE_LIBSELINUX" = yes; then + + cat >>confdefs.h <<\_ACEOF + #define HAVE_LIBSELINUX 1 + _ACEOF + + LIBSELINUX_LIBS=-lselinux + fi + fi + + HAVE_XAW3D=no + LUCID_LIBW= if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then if test "$with_xaw3d" != no; then { $as_echo "$as_me:$LINENO: checking for xaw3d" >&5 @@@ -13368,17 -13626,10 +13770,10 @@@ LIBS=$ac_check_lib_save_LIB fi { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_Xp_XpCreateContext" >&5 $as_echo "$ac_cv_lib_Xp_XpCreateContext" >&6; } -if test $ac_cv_lib_Xp_XpCreateContext = yes; then +if test "x$ac_cv_lib_Xp_XpCreateContext" = x""yes; then - HAVE_LIBXP=yes + LIBXP=-lXp fi - if test ${HAVE_LIBXP} = yes; then - - cat >>confdefs.h <<\_ACEOF - #define HAVE_LIBXP 1 - _ACEOF - - fi else { $as_echo "$as_me:$LINENO: checking for LessTif where some systems put it" >&5 $as_echo_n "checking for LessTif where some systems put it... " >&6; } diff --cc configure.in index e559d4f5756,491c3af9dce..cd6500b51e1 --- a/configure.in +++ b/configure.in @@@ -1597,25 -1752,7 +1753,23 @@@ if test "${HAVE_X11}" = "yes" || test " fi fi +HAVE_IMAGEMAGICK=no - if test "${HAVE_X11}" = "yes" ; then - if test "${with_imagemagick}" != "no"; then - IMAGEMAGICK_REQUIRED=1 - IMAGEMAGICK_MODULE="MagickWand >= $IMAGEMAGICK_REQUIRED" - - PKG_CHECK_MODULES(IMAGEMAGICK, $IMAGEMAGICK_MODULE, :, :) - AC_SUBST(IMAGEMAGICK_CFLAGS) - AC_SUBST(IMAGEMAGICK_LIBS) ++if test "${with_imagemagick}" != "no"; then ++ IMAGEMAGICK_REQUIRED=1 ++ IMAGEMAGICK_MODULE="MagickWand >= $IMAGEMAGICK_REQUIRED" ++ PKG_CHECK_MODULES(IMAGEMAGICK, $IMAGEMAGICK_MODULE, :, :) ++ AC_SUBST(IMAGEMAGICK_CFLAGS) ++ AC_SUBST(IMAGEMAGICK_LIBS) + - if test ".${IMAGEMAGICK_CFLAGS}" != "."; then - HAVE_IMAGEMAGICK=yes - AC_DEFINE(HAVE_IMAGEMAGICK, 1, [Define to 1 if using imagemagick.]) - CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS" - LIBS="$IMAGEMAGICK_LIBS $LIBS" - fi - fi ++ if test ".${IMAGEMAGICK_CFLAGS}" != "."; then ++ HAVE_IMAGEMAGICK=yes ++ AC_DEFINE(HAVE_IMAGEMAGICK, 1, [Define to 1 if using imagemagick.]) ++ CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS" ++ LIBS="$IMAGEMAGICK_LIBS $LIBS" ++ fi +fi + + HAVE_GTK=no if test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then GLIB_REQUIRED=2.6 diff --cc lisp/image.el index 963093c6149,67c1ad946b1..57e980c0afd --- a/lisp/image.el +++ b/lisp/image.el @@@ -690,31 -690,6 +690,31 @@@ shall be displayed. (cons images (+ (aref anim 1) (* (aref anim 2) 256)))))))) +(defconst imagemagick-types-inhibit + '(C HTML HTM TXT) - "Types the imagemagic loader should not try to handle.") ++ "Types the imagemagick loader should not try to handle.") + +;;;###autoload - (defun imagemagic-register-types () ++(defun imagemagick-register-types () + "Register file types that imagemagick is able to handle." + (let ((im-types (imagemagick-types)) + (im-inhibit imagemagick-types-inhibit)) + (while im-inhibit + (setq im-types (remove (car im-inhibit) im-types)) + (setq im-inhibit (cdr im-inhibit))) + (while im-types + (let + ((extension (downcase (symbol-name (car im-types))))) + (push + (cons (concat "\\." extension "\\'") 'image-mode) + auto-mode-alist) + (push + (cons (concat "\\." extension "\\'") 'imagemagick) + image-type-file-name-regexps) + (setq im-types (cdr im-types)))))) + + + (provide 'image) ;; arch-tag: 8e76a07b-eb48-4f3e-a7a0-1a7ba9f096b3 diff --cc src/Makefile.in index dada7164761,46d4e0c2878..2719f3a232a --- a/src/Makefile.in +++ b/src/Makefile.in @@@ -1,8 -1,7 +1,8 @@@ + # Makefile for GNU Emacs. # Copyright (C) 1985, 1987, 1988, 1993, 1994, 1995, 1999, 2000, 2001, 2002, - # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - # Free Software Foundation, Inc. + # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + # Free Software Foundation, Inc. # This file is part of GNU Emacs. @@@ -93,6 -137,31 +138,35 @@@ CFLAGS_SOUND= @CFLAGS_SOUND RSVG_LIBS= @RSVG_LIBS@ RSVG_CFLAGS= @RSVG_CFLAGS@ ++IMAGEMAGICK_LIBS= @IMAGEMAGICK_LIBS@ ++IMAGEMAGICK_CFLAGS= @IMAGEMAGICK_CFLAGS@ ++ ++ + ## widget.o if USE_X_TOOLKIT, otherwise empty. + WIDGET_OBJ=@WIDGET_OBJ@ + + ## sheap.o if CYGWIN, otherwise empty. + CYGWIN_OBJ=@CYGWIN_OBJ@ + + NS_OBJ=@NS_OBJ@ + NS_SUPPORT=@NS_SUPPORT@ + + ## Only used if HAVE_X_WINDOWS and HAVE_WINDOW_SYSTEM. + FONT_OBJ=@FONT_OBJ@ + + ## ${lispsource}mouse.elc if HAVE_GPM, otherwise empty. + ## Not used if HAVE_MOUSE. + GPM_MOUSE_SUPPORT=@GPM_MOUSE_SUPPORT@ + + BASE_WINDOW_SUPPORT=${lispsource}fringe.elc ${lispsource}image.elc \ + ${lispsource}international/fontset.elc ${lispsource}dnd.elc \ + ${lispsource}tool-bar.elc ${lispsource}mwheel.elc + + X_WINDOW_SUPPORT=${lispsource}x-dnd.elc ${lispsource}term/common-win.elc \ + ${lispsource}term/x-win.elc ${lispsource}dynamic-setting.elc + + LIBSELINUX_LIBS = @LIBSELINUX_LIBS@ + INTERVALS_H = dispextern.h intervals.h composite.h GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ @@@ -255,13 -226,10 +231,10 @@@ shared=n -DHAVE_CONFIG_H is needed for some other files to take advantage of the information in ``config.h''. */ - #undef C_SWITCH_MACHINE - #undef C_SWITCH_SYSTEM - #undef C_SWITCH_X_SITE - - /* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM + /* C_SWITCH_X_SITE must come before C_SWITCH_X_SYSTEM since it may have -I options that should override those two. */ - ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${IMAGEMAGICK_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS} + /* MYCPPFLAGS only referenced in etc/DEBUG. */ -ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} ${C_SWITCH_MACHINE} ${C_SWITCH_SYSTEM} @C_SWITCH_X_SITE@ @C_SWITCH_X_SYSTEM@ ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS} ++ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} ${C_SWITCH_MACHINE} ${C_SWITCH_SYSTEM} @C_SWITCH_X_SITE@ @C_SWITCH_X_SYSTEM@ ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${IMAGEMAGICK_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS} ALL_OBJC_CFLAGS=$(ALL_CFLAGS) @GNU_OBJC_CFLAGS@ .SUFFIXES: .m @@@ -832,11 -633,11 +638,11 @@@ SOME_MACHINE_LISP = ../lisp/mouse.elc duplicated symbols. If the standard libraries were compiled with GCC, we might need gnulib again after them. */ - LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(RSVG_LIBS) ${IMAGEMAGICK_LIBS} $(DBUS_LIBS) \ - @LIBGPM@ @LIBRESOLV@ LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \ - $(GETLOADAVG_LIBS) ${GCONF_LIBS} \ + LIBES = $(LOADLIBES) $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ - $(RSVG_LIBS) $(DBUS_LIBS) @LIBGPM@ @LIBRESOLV@ $(LIBS_SYSTEM) \ ++ $(RSVG_LIBS) ${IMAGEMAGICK_LIBS} $(DBUS_LIBS) @LIBGPM@ @LIBRESOLV@ $(LIBS_SYSTEM) \ + $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) ${GCONF_LIBS} ${LIBSELINUX_LIBS} \ @FREETYPE_LIBS@ @FONTCONFIG_LIBS@ @LIBOTF_LIBS@ @M17N_FLT_LIBS@ \ - $(GNULIB_VAR) LIB_MATH LIB_STANDARD $(GNULIB_VAR) + $(GNULIB_VAR) @LIB_MATH@ @LIB_STANDARD@ $(GNULIB_VAR) all: emacs${EXEEXT} $(OTHER_FILES) diff --cc src/config.in index e1837e74560,5fb0cd7d569..9020d976342 --- a/src/config.in +++ b/src/config.in @@@ -294,6 -294,6 +294,9 @@@ along with GNU Emacs. If not, see + +/* Load IMAGEMAGICK image IMG for use on frame F. Value is non-zero if + successful. this function will go into the imagemagick_type structure, and + the prototype thus needs to be compatible with that structure. */ + +static int +imagemagick_load (f, img) + struct frame *f; + struct image *img; +{ + int success_p = 0; + Lisp_Object file_name; + + /* If IMG->spec specifies a file name, create a non-file spec from it. */ + file_name = image_spec_value (img->spec, QCfile, NULL); + if (STRINGP (file_name)) + { + Lisp_Object file; + unsigned char *contents; + int size; + struct gcpro gcpro1; + + file = x_find_image_file (file_name); + GCPRO1 (file); + if (!STRINGP (file)) + { + image_error ("Cannot find image file `%s'", file_name, Qnil); + UNGCPRO; + return 0; + } + + /* Read the entire file into memory. */ + /* contents = slurp_file (SDATA (file), &size); */ + /* if (contents == NULL) */ + /* { */ + /* image_error ("Error loading IMAGEMAGICK image `%s'", img->spec, Qnil); */ + /* UNGCPRO; */ + /* return 0; */ + /* } */ + /* If the file was slurped into memory properly, parse it. */ + success_p = imagemagick_load_image (f, img, 0, 0, SDATA(file_name)); + UNGCPRO; + } + /* Else its not a file, its a lisp object. Load the image from a + lisp object rather than a file. */ + else + { + Lisp_Object data; + + data = image_spec_value (img->spec, QCdata, NULL); + success_p = imagemagick_load_image (f, img, SDATA (data), SBYTES (data),NULL); + } + + return success_p; +} + +/* imagemagick_load_image is a helper function for imagemagick_load, which does the + actual loading given contents and size, apart from frame and image + structures, passed from imagemagick_load. + + Uses librimagemagick to do most of the image processing. + + Returns non-zero when successful. +*/ + +static int +imagemagick_load_image (f, img, contents, size, filename) + /* Pointer to emacs frame structure. */ + struct frame *f; + /* Pointer to emacs image structure. */ + struct image *img; + /* String containing the IMAGEMAGICK data to be parsed. */ + unsigned char *contents; + /* Size of data in bytes. */ + unsigned int size; + /* Filename, either pass filename or contents/size. */ + unsigned char *filename; +{ + long unsigned int width; + long unsigned int height; + + MagickBooleanType + status; + + XImagePtr ximg; + Lisp_Object specified_bg; + XColor background; + int x; + int y; + + MagickWand *image_wand; + PixelIterator *iterator; + PixelWand **pixels; + MagickPixelPacket pixel; + + + /* image_wand will contain the image. */ + image_wand = NewMagickWand(); + + /* Parse the contents argument and initialize image_wand. */ + if(filename!=NULL) + status=MagickReadImage(image_wand, filename); + else + status=MagickReadImageBlob(image_wand, contents, size); + image_error ("im read failed", Qnil, Qnil); + if (status == MagickFalse) goto imagemagick_error; + + /* Handle image index for image types who can contain more than one image. + Interface :index is same as for GIF. */ + Lisp_Object image; + long ino; + image = image_spec_value (img->spec, QCindex, NULL); + ino = INTEGERP (image) ? XFASTINT (image) : 0; + + /* if (ino >= ) */ + /* { */ + /* image_error ("Invalid image number `%s' in image `%s'", */ + /* image, img->spec); */ + /* UNGCPRO; */ + /* return 0; */ + /* } */ + + if(ino==0) + MagickSetFirstIterator(image_wand); + else + MagickSetIteratorIndex(image_wand, ino); + + /* + If width and/or height is set in the display spec + assume we want to scale to those. */ + + int desired_width, desired_height; + Lisp_Object value; + value = image_spec_value (img->spec, QCwidth, NULL); + desired_width = (INTEGERP (value) ? XFASTINT (value) : -1); + value = image_spec_value (img->spec, QCheight, NULL); + desired_height = (INTEGERP (value) ? XFASTINT (value) : -1); + if(desired_width != -1 && desired_height != -1){ + printf("MagickScaleImage %d %d\n",desired_width, desired_height); + status=MagickScaleImage(image_wand, desired_width, desired_height); + if (status == MagickFalse) { + image_error ("Imagemagick scale failed", Qnil, Qnil); + goto imagemagick_error; + } + + } + + /* Also support :geometry and :crop which are imagemagick specific descriptors. */ + + Lisp_Object crop, geometry; + crop = image_spec_value (img->spec, QCcrop, NULL); + geometry = image_spec_value (img->spec, QCgeometry, NULL); + if (STRINGP (crop) && STRINGP (geometry)){ + printf("MagickTransformImage %s %s\n",SDATA(crop), SDATA(geometry)); + image_wand = MagickTransformImage (image_wand, SDATA (crop), SDATA (geometry)); + /* TODO differ between image_wand and transform_wand. */ + } + + /* Furthermore :rotation. we need background color and angle for rotation. */ + /* + TODO background handling for rotation + specified_bg = image_spec_value (img->spec, QCbackground, NULL); + if (!STRINGP (specified_bg) + */ + double rotation; + value = image_spec_value (img->spec, QCrotation, NULL); + if (FLOATP (value)){ + PixelWand* background = NewPixelWand(); + PixelSetColor (background, "#ffffff");/*TODO remove hardcode*/ + + rotation = extract_float (value); + printf ("MagickRotateImage %f\n",rotation); + + status=MagickRotateImage (image_wand, background,rotation); + DestroyPixelWand (background); + if (status == MagickFalse) { + image_error ("Imagemagick image rotate failed", Qnil, Qnil); + goto imagemagick_error; + } + } + + /* Finaly we are done manipulating the image, + figure out resulting width, height, and then transfer ownerwship to Emacs. + */ + height=MagickGetImageHeight (image_wand); + width=MagickGetImageWidth (image_wand); + if (status == MagickFalse) { + image_error ("Imagemagick image get size failed", Qnil, Qnil); + goto imagemagick_error; + } + + if (! check_image_size (f, width, height)) + { + image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); + goto imagemagick_error; + } + + /* We can now get a valid pixel buffer from the imagemagick file, if all + went ok. */ + + + init_color_table (); + int imagemagick_rendermethod=(INTEGERP (Vimagemagick_render_type) ? XFASTINT (Vimagemagick_render_type) : 0); + if (imagemagick_rendermethod==0){ + /* Try to create a x pixmap to hold the imagemagick pixmap. */ + if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)){ + image_error("Imagemagick X bitmap allocation failure",Qnil,Qnil); + goto imagemagick_error; + } + + /* Copy imagegmagick image to x with primitive yet robust pixel + pusher loop. This has been tested a lot with many different + images, it doesnt work too well with image archive formats though! + + Also seems slow. + */ + + /* Copy pixels from the imagemagick image structure to the x image map. */ + iterator = NewPixelIterator (image_wand); + if ((iterator == (PixelIterator *) NULL)) { + image_error ("Imagemagick pixel iterator creation failed", Qnil, Qnil); + goto imagemagick_error; + } + + for (y=0; y < (long) MagickGetImageHeight(image_wand); y++) + { + pixels = PixelGetNextIteratorRow (iterator, &width); + if ((pixels == (PixelWand **) NULL)) + break; + for (x=0; x < (long) width; x++) + { + PixelGetMagickColor (pixels[x], &pixel); + XPutPixel (ximg, x, y, lookup_rgb_color (f, pixel.red, pixel.green, pixel.blue)); + } + } + DestroyPixelIterator (iterator); + } + + if (imagemagick_rendermethod==1){ + /* Try if magicexportimage is any faster than pixelpushing. */ + /* printf("ximg: bitmap_unit:%d format:%d byte_order:%d depth:%d bits_per_pixel:%d\n", */ + /* ximg->bitmap_unit,ximg->format,ximg->byte_order,ximg->depth,ximg->bits_per_pixel); */ + int imagedepth=24;/*MagickGetImageDepth(image_wand);*/ + char* exportdepth= imagedepth <= 8 ? "I" : "BGRP";/*"RGBP";*/ + /* Try to create a x pixmap to hold the imagemagick pixmap. */ + printf("imagedepth:%d exportdepth:%s\n", imagedepth, exportdepth); + if (!x_create_x_image_and_pixmap (f, width, height, imagedepth, &ximg, &img->pixmap)){ + image_error("Imagemagick X bitmap allocation failure",Qnil,Qnil); + goto imagemagick_error; + } + + + /* Oddly, the below code doesnt seem to work:*/ + int pixelwidth; + /* switch(ximg->bitmap_unit){ */ + /* case 8: */ + /* pixelwidth=CharPixel; */ + /* break; */ + /* case 16: */ + /* pixelwidth=ShortPixel; */ + /* break; */ + /* case 32: */ + /* pixelwidth=LongPixel; */ + /* break; */ + /* } */ + /* + Here im just guessing the format of the bitmap. + happens to work fine for: + - bw djvu images + on rgb display. + seems about 3 times as fast as pixel pushing(not carefully measured) + with color djvu, the bitplanes are mapped to wrong color(seems fixed). + + */ + pixelwidth=CharPixel;/*??? TODO figure out*/ + MagickExportImagePixels(image_wand, + 0,0, + width,height, + exportdepth, + pixelwidth, + /*&(img->pixmap));*/ + ximg->data); + } + +#ifdef COLOR_TABLE_SUPPORT + /* Remember colors allocated for this image. */ + img->colors = colors_in_color_table (&img->ncolors); + free_color_table (); +#endif /* COLOR_TABLE_SUPPORT */ + + + img->width = width; + img->height = height; + + /* Maybe fill in the background field while we have ximg handy. + Casting avoids a GCC warning. */ + /* IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);*/ + + /* Put the image into the pixmap, then free the X image and its + buffer. */ + x_put_x_image (f, ximg, img->pixmap, width, height); + + x_destroy_x_image (ximg); + + + /* JAVE TODO more cleanup. */ + DestroyMagickWand (image_wand); + + return 1; + + imagemagick_error: + /* TODO more cleanup. */ + image_error ("Error parsing IMAGEMAGICK image `%s'", img->spec, Qnil); + printf("Imagemagick error, see *Messages*\n"); + return 0; +} + +DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0,0,0, + doc: /* Return image file types supported by ImageMagick. - Since ImageMagic recognizes a lot of file-types that clash with Emacs, ++ Since ImageMagick recognizes a lot of file-types that clash with Emacs, + such as .c, we want to be able to alter the list at the lisp level. */) + () +{ + Lisp_Object typelist = Qnil; + unsigned long numf; + ExceptionInfo ex; + char** imtypes = GetMagickList ("*", &numf, &ex); + int i; + Lisp_Object Qimagemagicktype; + for (i = 0; i < numf; i++) { + Qimagemagicktype = intern (*( imtypes + i)); + typelist = Fcons (Qimagemagicktype, typelist); + } + return typelist; +} + +#endif /* defined (HAVE_IMAGEMAGICK) */ + + /*********************************************************************** SVG