;ELC ;;; Compiled by cyd@localhost on Mon Apr 23 22:20:53 2007 ;;; from file /home/cyd/emacs/lisp/image.el ;;; in Emacs version 22.0.99 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. (if (and (boundp 'emacs-version) (< (aref emacs-version (1- (length emacs-version))) ?A) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19.29"))) (error "`image.el' was compiled for Emacs 19.29 or later")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (custom-declare-group 'image nil "Image support." :group 'multimedia) #@400 Alist of (REGEXP . IMAGE-TYPE) pairs used to auto-detect image types. When the first bytes of an image file match REGEXP, it is assumed to be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol. If not a symbol, IMAGE-TYPE must be a pair (PREDICATE . TYPE). PREDICATE is called with one argument, a string containing the image data. If PREDICATE returns a non-nil value, TYPE is the image's type. (defconst image-type-header-regexps '(("\\`/[ \n ]*\\*.*XPM.\\*/" . xpm) ("\\`P[1-6][[:space:]]+\\(?:#.*[[:space:]]+\\)*[0-9]+[[:space:]]+[0-9]+" . pbm) ("\\`GIF8[79]a" . gif) ("\\`\x89PNG \n\n" . png) ("\\`[ \n ]*#define \\([a-z0-9]+\\)_width [0-9]+\n#define \\1_height [0-9]+\nstatic char \\1_bits" . xbm) ("\\`\\(?:MM\\*\\|II\\*\\)" . tiff) ("\\`[ \n ]*%!PS" . postscript) ("\\`\xff\xd8" image-jpeg-p . jpeg)) (#$ . 628)) #@159 Alist of (REGEXP . IMAGE-TYPE) pairs used to identify image files. When the name of an image file match REGEXP, it is assumed to be of image type IMAGE-TYPE. (defconst image-type-file-name-regexps '(("\\.png\\'" . png) ("\\.gif\\'" . gif) ("\\.jpe?g\\'" . jpeg) ("\\.bmp\\'" . bmp) ("\\.xpm\\'" . xpm) ("\\.pbm\\'" . pbm) ("\\.xbm\\'" . xbm) ("\\.ps\\'" . postscript) ("\\.tiff?\\'" . tiff)) (#$ . 1465)) #@284 Alist of (IMAGE-TYPE . AUTODETECT) pairs used to auto-detect image files. (See `image-type-auto-detected-p'). AUTODETECT can be - t always auto-detect. - nil never auto-detect. - maybe auto-detect only if the image type is available (see `image-type-available-p'). (defvar image-type-auto-detectable '((pbm . t) (xbm) (bmp . maybe) (gif . maybe) (png . maybe) (xpm) (jpeg . maybe) (tiff . maybe) (postscript)) (#$ . 1877)) #@330 List of locations in which to search for image files. If an element is a string, it defines a directory to search. If an element is a variable symbol whose value is a string, that value defines a directory to search. If an element is a variable symbol whose value is a list, the value is used as a list of directories to search. (defvar image-load-path nil (#$ . 2325)) (byte-code "\203\303\304\305 \"!\301\306E\202\307\310\311\312#\210\303\207" [command-line-processed data-directory image-load-path file-name-as-directory expand-file-name #1="images" load-path add-hook before-init-hook (lambda nil "From no file" (setq image-load-path (list (file-name-as-directory (expand-file-name #1# data-directory)) 'data-directory 'load-path))) t] 4) #@1196 Return a suitable search path for images used by LIBRARY. It searches for IMAGE in `image-load-path' (excluding "`data-directory'/images") and `load-path', followed by a path suitable for LIBRARY, which includes "../../etc/images" and "../etc/images" relative to the library file itself, and then in "`data-directory'/images". Then this function returns a list of directories which contains first the directory in which IMAGE was found, followed by the value of `load-path'. If PATH is given, it is used instead of `load-path'. If NO-ERROR is non-nil and a suitable path can't be found, don't signal an error. Instead, return a list of directories as before, except that nil appears in place of the image directory. Here is an example that uses a common idiom to provide compatibility with versions of Emacs that lack the variable `image-load-path': ;; Shush compiler. (defvar image-load-path) (let* ((load-path (image-load-path-for-library "mh-e" "mh-logo.xpm")) (image-load-path (cons (car load-path) (when (boundp 'image-load-path) image-load-path)))) (mh-tool-bar-folder-buttons-init)) (defalias 'image-load-path-for-library #[(library image &optional path no-error) "\204\306\307!\210 \204\306\310!\210\311\211 \312 !\206\313 !\311 \203A\314 !\314!\211\203A\315\f!\316\317 \"\202+ +\n\203Y\n\320\316\321\"!\232\204Y\n\202\306\311\211\211\313!\211\204p\306\322\"\210\320\316\314!\323P!!\320\316\314!\324P!!\325\316 \"!\203\227\202\243\325\316 \"!\205\243\211+\204\306\n\203\262\n\202\306\203\300\326\327 #\210\202\306\306\327 #\210 C\330 \331 \206\322!!\"\244*\207" [library image image-directory-load-path image-directory parent dir error "No library specified" "No image specified" nil image-search-load-path locate-library file-name-directory directory-file-name expand-file-name "../" file-name-as-directory "images" "Cannot find library %s in load-path" "../../etc/images" "../etc/images" file-exists-p message "Could not find image %s for library %s" delete copy-sequence img data-directory d2ei d1ei library-name no-error path load-path] 6 (#$ . 3082)]) #@122 Value is non-nil if DATA, a string, consists of JFIF image data. We accept the tag Exif because that is the same format. (defalias 'image-jpeg-p #[(data) "\301\302\"\205\n\303\304\215\207" [data string-match "\\`\xff\xd8" jfif (byte-code "G\305 \nW\205_ H\306U\204\307\310\311\"\210 T\211\305\\\nY\203(\307\310\311\"\210\312 TH\313\" \305\\H\\ H \314Y\203U \315X\203U\307\310\316\317 \211\f\\\n^O\"\"\210 \f\\\320\\*\202*\207" [data i len code nbytes 2 255 throw jfif nil lsh 8 224 239 string-match "JFIF\\|Exif" 1] 9)] 3 (#$ . 5333)]) #@129 Determine the image type from image data DATA. Value is a symbol specifying the image type or nil if type cannot be determined. (defalias 'image-type-from-data #[(data) "\306\n\203=\n@@\n@A 9\203\307\f \"\204/ :\2036 @ !\2036 A\211\2036 \306\2029\nA*\202 *\207" [image-type-header-regexps type types image-type regexp data nil string-match] 3 (#$ . 5898)]) #@140 Determine the image type from data in the current buffer. Value is a symbol specifying the image type or nil if type cannot be determined. (defalias 'image-type-from-buffer #[nil "\306`eb\210 \203Q @@ @A\306 9\203$\307 !\204C :\203J @\f\2068ede\310\\^{\211!\203J A\211\203J \306\202M A+\202 b\210\n+\207" [image-type-header-regexps opoint type types data image-type nil looking-at 256 regexp] 5 (#$ . 6281)]) #@147 Determine the type of image file FILE from its first few bytes. Value is a symbol specifying the image type, or nil if type cannot be determined. (defalias 'image-type-from-file-header #[(file) "\302!\204\303!\204\304!\2052\302!\2052\305\306!\307\216r q\210\310\311!\210\312\311\313\314$\210\315 +\207" [file #1=#:temp-buffer file-readable-p file-name-absolute-p image-search-load-path generate-new-buffer " *temp*" ((byte-code "\301!\203\n\302!\210\301\207" [#1# buffer-name kill-buffer] 2)) set-buffer-multibyte nil insert-file-contents-literally 0 256 image-type-from-buffer] 5 (#$ . 6721)]) #@136 Determine the type of image file FILE from its name. Value is a symbol specifying the image type, or nil if type cannot be determined. (defalias 'image-type-from-file-name #[(file) "\304\211\203\"\305\n@@ \"\203\n@A\304\211\202\nA\211\204 *\207" [image-type-file-name-regexps type types file nil string-match] 4 (#$ . 7340)]) #@409 Determine and return image type. FILE-OR-DATA is an image file name or image data. Optional TYPE is a symbol describing the image type. If TYPE is omitted or nil, try to determine the image type from its first few bytes of image data. If that doesn't work, and FILE-OR-DATA is a file name, use its file extension as image type. Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data. (defalias 'image-type #[(file-or-data &optional type data-p) "\204 ;\204\304\305 \"\210\2042\n\204:\306 !\211\204:\307 !\211\204*\304\310!\210\311 !)\202:\n\204:\312 !\n\204B\304\310!\210\n9\204L\304\313\n\"\210\n\207" [data-p file-or-data type extension error "Invalid image file name `%s'" image-type-from-file-header file-name-extension "Cannot determine image type" intern image-type-from-data "Invalid image type `%s'"] 4 (#$ . 7686)]) #@95 Return non-nil if image type TYPE is available. Image types are symbols like `xbm' or `jpeg'. (defalias 'image-type-available-p #[(type) "\302\303!\205\n\303 \"\207" [type image-library-alist fboundp init-image-library] 3 (#$ . 8559)]) #@599 Return t iff the current buffer contains an auto-detectable image. This function is intended to be used from `magic-mode-alist' (which see). First, compare the beginning of the buffer with `image-type-header-regexps'. If an appropriate image type is found, check if that image type can be autodetected using the variable `image-type-auto-detectable'. Finally, if `buffer-file-name' is non-nil, check if it matches another major mode in `auto-mode-alist' apart from `image-mode'; if there is another match, the autodetection is considered to have failed. Return t if all the above steps succeed. (defalias 'image-type-auto-detected-p #[nil "\305 \211\205  \236A\211\205-\n\306=\204\307!\205- ?\206-\310 \311\312\313\314\f\"\"\315#?*\207" [type image-type-auto-detectable auto buffer-file-name auto-mode-alist image-type-from-buffer t image-type-available-p assoc-default delq nil mapcar #[(elt) "A\242\206A\301>?\205\207" [elt (image-mode image-mode-maybe)] 2] string-match] 8 (#$ . 8804)]) #@631 Create an image. FILE-OR-DATA is an image file name or image data. Optional TYPE is a symbol describing the image type. If TYPE is omitted or nil, try to determine the image type from its first few bytes of image data. If that doesn't work, and FILE-OR-DATA is a file name, use its file extension as image type. Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data. Optional PROPS are additional image attributes to assign to the image, like, e.g. `:mask MASK'. Value is the image created, or nil if images of type TYPE are not supported. Images should not be larger than specified by `max-image-size'. (defalias 'create-image #[(file-or-data &optional type data-p &rest props) "\304 \n#\305 !\205\306\307\310 \n\203\311\202\312\257 \"\207" [file-or-data type data-p props image-type image-type-available-p append image :type :data :file] 6 (#$ . 9821)]) #@575 Put image IMAGE in front of POS in the current buffer. IMAGE must be an image created with `create-image' or `defimage'. IMAGE is displayed by putting an overlay into the current buffer with a `before-string' STRING that has a `display' property whose value is the image. STRING is defaulted if you omit it. POS may be an integer or marker. AREA is where to display the image. AREA nil or omitted means display it in the text area, a value of `left-margin' means display it in the left marginal area, a value of `right-margin' means display it in the right marginal area. (defalias 'put-image #[(image pos &optional string area) "\204\306p\n\242\302=\204\307\310\n\"\210 \203# \311>\204#\307\312 \"\210\313!\314\f\211 # \2044\n\2029\315 D\nD\316\317G\320 %\210\321\322\323#\210\321\324#+\207" [string buffer image area pos prop "x" error "Not an image: %s" (left-margin right-margin) "Invalid area %s" copy-sequence make-overlay margin put-text-property 0 display overlay-put put-image t before-string overlay] 6 (#$ . 10720)]) #@752 Insert IMAGE into current buffer at point. IMAGE is displayed by inserting STRING into the current buffer with a `display' property whose value is the image. STRING is defaulted if you omit it. AREA is where to display the image. AREA nil or omitted means display it in the text area, a value of `left-margin' means display it in the left marginal area, a value of `right-margin' means display it in the right marginal area. SLICE specifies slice of IMAGE to insert. SLICE nil or omitted means insert whole image. SLICE is a list (X Y WIDTH HEIGHT) specifying the X and Y positions and WIDTH and HEIGHT of image area to insert. A float value 0.0 - 1.0 means relative to the width or height of the image; integer values are taken as pixel values. (defalias 'insert-image #[(image &optional string area slice) "\204\305 \242\301=\204\306\307 \"\210\n\203!\n\310>\204!\306\311\n\"\210\n\203.\312\nD D\2023\301 AB`c\210\313 `\314\f\203H\304\fB D\202I \315BB#)\207" [string image area start slice " " error "Not an image: %s" (left-margin right-margin) "Invalid area %s" margin add-text-properties display (rear-nonsticky (display))] 6 (#$ . 11780)]) #@485 Insert IMAGE into current buffer at point. IMAGE is displayed by inserting STRING into the current buffer with a `display' property whose value is the image. STRING is defaulted if you omit it. AREA is where to display the image. AREA nil or omitted means display it in the text area, a value of `left-margin' means display it in the left marginal area, a value of `right-margin' means display it in the right marginal area. The image is automatically split into ROW x COLS slices. (defalias 'insert-sliced-image #[(image &optional string area rows cols) "\204\306 \242\301=\204\307\310 \"\210\n\203!\n\311>\204!\307\312\n\"\210\n\203.\313\nD D\2023\301 AB\314\315 \206:\316\245\317\320\f\206B\316\245\321W\205\222\322W\203`c\210\323`\324\325 \257 D\326BB#\210\\)\202Q\327 \\\330\331\332\333#c\210\202J,\207" [string image area cols rows dy " " error "Not an image: %s" (left-margin right-margin) "Invalid area %s" margin 0.0 1.0001 1 0.0 1.0001 1.0 1.0 add-text-properties display slice (rear-nonsticky (display)) 0.0 propertize "\n" line-height t y dx x start] 9 (#$ . 12954)]) #@170 Remove images between START and END in BUFFER. Remove only images that were put in BUFFER with calls to `put-image'. BUFFER nil or omitted means use the current buffer. (defalias 'remove-images #[(start end &optional buffer) "\204p\305 \n\"\211\205& @\306\f\307\"\203\310\f!\210) A\211\204\311)\207" [buffer start end overlays overlay overlays-in overlay-get put-image delete-overlay nil] 4 (#$ . 14097)]) (defalias 'image-search-load-path #[(file &optional path) "\204 \306\211\211 \204^:\203^@\211;\203)\307\310 \f\"\211!\202X\f9\203X\311\f!\203X\fJ\211;\203H\307\310 \f\"\211!\202X\f:\203X\312 \f\"\211\203X\313A\202\f \205c\n+\207" [path image-load-path filename found element file nil file-readable-p expand-file-name boundp image-search-load-path t] 5]) #@774 Find an image, choosing one of a list of image specifications. SPECS is a list of image specifications. Each image specification in SPECS is a property list. The contents of a specification are image type dependent. All specifications must at least contain the properties `:type TYPE' and either `:file FILE' or `:data DATA', where TYPE is a symbol specifying the image type, e.g. `xbm', FILE is the file to load the image from, and DATA is a string containing the actual image data. The specification whose TYPE is supported, and FILE exists, is used to construct the image specification to be returned. Return nil if no specification is satisfied. The image is looked for in `image-load-path'. Image files should not be larger than specified by `max-image-size'. (defalias 'find-image #[(specs) "\306 \203P\204P @\307\n\310\"\307\n\311\"\307\n\312\"\306\313 !\203I ;\203A\314 !\211\203I\300\315\316\n!\312#B\202I\f\203I\300\nB A-\202)\207" [image specs spec type data file nil plist-get :type :data :file image-type-available-p image-search-load-path plist-put copy-sequence found] 5 (#$ . 14907)])(if macro-declaration-function (funcall macro-declaration-function (quote defimage) (quote (declare (doc-string 3))))) #@721 Define SYMBOL as an image. SPECS is a list of image specifications. DOC is an optional documentation string. Each image specification in SPECS is a property list. The contents of a specification are image type dependent. All specifications must at least contain the properties `:type TYPE' and either `:file FILE' or `:data DATA', where TYPE is a symbol specifying the image type, e.g. `xbm', FILE is the file to load the image from, and DATA is a string containing the actual image data. The first image specification whose TYPE is supported, and FILE exists, is used to define SYMBOL. Example: (defimage test-image ((:type xpm :file "~/test1.xpm") (:type xbm :file "~/test1.xbm"))) (defalias 'defimage '(macro . #[(symbol specs &optional doc) "\303\304\305 DD\nF\207" [symbol specs doc defvar find-image quote] 5 (#$ . 16166)])) (provide 'image)