aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2006-04-21 20:56:06 +0000
committerKim F. Storm2006-04-21 20:56:06 +0000
commite796837385175997fd30d907d0cd7fac06617dcd (patch)
tree450730d88e518ca6f28b8f32031dace47b9f51da
parent15855f8f789cbe98f2df394904350bfaec71bd53 (diff)
downloademacs-e796837385175997fd30d907d0cd7fac06617dcd.tar.gz
emacs-e796837385175997fd30d907d0cd7fac06617dcd.zip
(image-type): New defun split out of create-image.
(create-image): Use it.
-rw-r--r--lisp/image.el44
1 files changed, 28 insertions, 16 deletions
diff --git a/lisp/image.el b/lisp/image.el
index 2212b0fb471..b388396ded7 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -280,27 +280,14 @@ be determined."
280 280
281 281
282;;;###autoload 282;;;###autoload
283(defun image-type-available-p (type) 283(defun image-type (file-or-data &optional type data-p)
284 "Return non-nil if image type TYPE is available. 284 "Determine and return image type.
285Image types are symbols like `xbm' or `jpeg'."
286 (and (fboundp 'init-image-library)
287 (init-image-library type image-library-alist)))
288
289
290;;;###autoload
291(defun create-image (file-or-data &optional type data-p &rest props)
292 "Create an image.
293FILE-OR-DATA is an image file name or image data. 285FILE-OR-DATA is an image file name or image data.
294Optional TYPE is a symbol describing the image type. If TYPE is omitted 286Optional TYPE is a symbol describing the image type. If TYPE is omitted
295or nil, try to determine the image type from its first few bytes 287or nil, try to determine the image type from its first few bytes
296of image data. If that doesn't work, and FILE-OR-DATA is a file name, 288of image data. If that doesn't work, and FILE-OR-DATA is a file name,
297use its file extension as image type. 289use its file extension as image type.
298Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data. 290Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data."
299Optional PROPS are additional image attributes to assign to the image,
300like, e.g. `:mask MASK'.
301Value is the image created, or nil if images of type TYPE are not supported.
302
303Images should not be larger than specified by `max-image-size'."
304 (when (and (not data-p) (not (stringp file-or-data))) 291 (when (and (not data-p) (not (stringp file-or-data)))
305 (error "Invalid image file name `%s'" file-or-data)) 292 (error "Invalid image file name `%s'" file-or-data))
306 (cond ((null data-p) 293 (cond ((null data-p)
@@ -319,6 +306,31 @@ Images should not be larger than specified by `max-image-size'."
319 (error "Cannot determine image type")) 306 (error "Cannot determine image type"))
320 (unless (symbolp type) 307 (unless (symbolp type)
321 (error "Invalid image type `%s'" type)) 308 (error "Invalid image type `%s'" type))
309 type)
310
311;;;###autoload
312(defun image-type-available-p (type)
313 "Return non-nil if image type TYPE is available.
314Image types are symbols like `xbm' or `jpeg'."
315 (and (fboundp 'init-image-library)
316 (init-image-library type image-library-alist)))
317
318
319;;;###autoload
320(defun create-image (file-or-data &optional type data-p &rest props)
321 "Create an image.
322FILE-OR-DATA is an image file name or image data.
323Optional TYPE is a symbol describing the image type. If TYPE is omitted
324or nil, try to determine the image type from its first few bytes
325of image data. If that doesn't work, and FILE-OR-DATA is a file name,
326use its file extension as image type.
327Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data.
328Optional PROPS are additional image attributes to assign to the image,
329like, e.g. `:mask MASK'.
330Value is the image created, or nil if images of type TYPE are not supported.
331
332Images should not be larger than specified by `max-image-size'."
333 (setq type (image-type file-or-data type data-p))
322 (when (image-type-available-p type) 334 (when (image-type-available-p type)
323 (append (list 'image :type type (if data-p :data :file) file-or-data) 335 (append (list 'image :type type (if data-p :data :file) file-or-data)
324 props))) 336 props)))