46 |
be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol. If not a symbol, |
be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol. If not a symbol, |
47 |
IMAGE-TYPE must be a pair (PREDICATE . TYPE). PREDICATE is called |
IMAGE-TYPE must be a pair (PREDICATE . TYPE). PREDICATE is called |
48 |
with one argument, a string containing the image data. If PREDICATE returns |
with one argument, a string containing the image data. If PREDICATE returns |
49 |
a non-nil value, TYPE is the image's type ") |
a non-nil value, TYPE is the image's type.") |
50 |
|
|
51 |
|
|
52 |
(defun image-jpeg-p (data) |
(defun image-jpeg-p (data) |
53 |
"Value is non-nil if DATA, a string, consists of JFIF image data." |
"Value is non-nil if DATA, a string, consists of JFIF image data. |
54 |
|
We accept the tag Exif because that is the same format." |
55 |
(when (string-match "\\`\xff\xd8" data) |
(when (string-match "\\`\xff\xd8" data) |
56 |
(catch 'jfif |
(catch 'jfif |
57 |
(let ((len (length data)) (i 2)) |
(let ((len (length data)) (i 2)) |
66 |
(code (aref data i))) |
(code (aref data i))) |
67 |
(when (and (>= code #xe0) (<= code #xef)) |
(when (and (>= code #xe0) (<= code #xef)) |
68 |
;; APP0 LEN1 LEN2 "JFIF\0" |
;; APP0 LEN1 LEN2 "JFIF\0" |
69 |
(throw 'jfif |
(throw 'jfif |
70 |
(string-match "JFIF" (substring data i (+ i nbytes))))) |
(string-match "JFIF\\|Exif" (substring data i (+ i nbytes))))) |
71 |
(setq i (+ i 1 nbytes)))))))) |
(setq i (+ i 1 nbytes)))))))) |
72 |
|
|
73 |
|
|
203 |
(let ((start (point))) |
(let ((start (point))) |
204 |
(insert string) |
(insert string) |
205 |
(add-text-properties start (point) |
(add-text-properties start (point) |
206 |
(list 'display image |
`(display ,image rear-nonsticky (display))))) |
|
;; `image' has the right properties to |
|
|
;; mark an intangible field. |
|
|
'intangible image |
|
|
'rear-nonsticky (list 'display))))) |
|
207 |
|
|
208 |
|
|
209 |
;;;###autoload |
;;;###autoload |