Changeset 3001
- Timestamp:
- 02/19/03 20:12:19 (6 years ago)
- Files:
-
- work/cvs2svn/lisp/ChangeLog.Meadow (modified) (1 diff)
- work/cvs2svn/lisp/image.el (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
work/cvs2svn/lisp/ChangeLog.Meadow
r2990 r3001 1 2003-02-19 MIYOSHI Masanori <miyoshi@boreas.dti.ne.jp> 2 3 * image.el (image-type-from-file-header): Make temporary buffer 4 unibyte. This code is imported from emacs-21.3.50. 5 1 6 2003-02-12 MIYOSHI Masanori <miyoshi@boreas.dti.ne.jp> 2 7 work/cvs2svn/lisp/image.el
r2403 r3001 32 32 33 33 (defconst image-type-regexps 34 '((" ^/\\*.*XPM.\\*/" . xpm)35 (" ^P[1-6]" . pbm)36 (" ^GIF8" . gif)37 (" JFIF" . jpeg)38 (" ^\211PNG\r\n" . png)39 (" ^#define" . xbm)40 (" ^\\(MM\0\\*\\)\\|\\(II\\*\0\\)" . tiff)41 (" ^%!PS" . postscript))34 '(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm) 35 ("\\`P[1-6]" . pbm) 36 ("\\`GIF8" . gif) 37 ("\\`\211PNG\r\n" . png) 38 ("\\`[\t\n\r ]*#define" . xbm) 39 ("\\`\\(MM\0\\*\\|II\\*\0\\)" . tiff) 40 ("\\`[\t\n\r ]*%!PS" . postscript) 41 ("\\`\xff\xd8" . (image-jpeg-p . jpeg))) 42 42 "Alist of (REGEXP . IMAGE-TYPE) pairs used to auto-detect image types. 43 43 When the first bytes of an image file match REGEXP, it is assumed to 44 be of image type IMAGE-TYPE.") 44 be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol. If not a symbol, 45 IMAGE-TYPE must be a pair (PREDICATE . TYPE). PREDICATE is called 46 with one argument, a string containing the image data. If PREDICATE returns 47 a non-nil value, TYPE is the image's type ") 48 49 50 (defun image-jpeg-p (data) 51 "Value is non-nil if DATA, a string, consists of JFIF image data." 52 (when (string-match "\\`\xff\xd8" data) 53 (catch 'jfif 54 (let ((len (length data)) (i 2)) 55 (while (< i len) 56 (when (/= (aref data i) #xff) 57 (throw 'jfif nil)) 58 (setq i (1+ i)) 59 (when (>= (+ i 2) len) 60 (throw 'jfif nil)) 61 (let ((nbytes (+ (lsh (aref data (+ i 1)) 8) 62 (aref data (+ i 2)))) 63 (code (aref data i))) 64 (when (and (>= code #xe0) (<= code #xef)) 65 ;; APP0 LEN1 LEN2 "JFIF\0" 66 (throw 'jfif 67 (string-match "JFIF" (substring data i (+ i nbytes))))) 68 (setq i (+ i 1 nbytes)))))))) 45 69 46 70 … … 55 79 (let ((regexp (car (car types))) 56 80 (image-type (cdr (car types)))) 57 (when (string-match regexp data) 81 (when (or (and (symbolp image-type) 82 (string-match regexp data)) 83 (and (consp image-type) 84 (funcall (car image-type) data) 85 (setq image-type (cdr image-type)))) 58 86 (setq type image-type)) 59 87 (setq types (cdr types)))) … … 70 98 (setq file (expand-file-name file)) 71 99 (let ((header (with-temp-buffer 100 (set-buffer-multibyte nil) 72 101 (insert-file-contents-literally file nil 0 256) 73 102 (buffer-string))))
