]> code.delx.au - gnu-emacs/blobdiff - lisp/image-mode.el
Update copyright year to 2015
[gnu-emacs] / lisp / image-mode.el
index 492ac10d706c2f3dd529fb3eb2b2a444ee3af212..9e527f1f0b3373de00974d9d92b036de9dab646f 100644 (file)
@@ -1,6 +1,6 @@
 ;;; image-mode.el --- support for visiting image files  -*- lexical-binding: t -*-
 ;;
-;; Copyright (C) 2005-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2015 Free Software Foundation, Inc.
 ;;
 ;; Author: Richard Stallman <rms@gnu.org>
 ;; Keywords: multimedia
   "Special hook run when image data is requested in a new window.
 It is called with one argument, the initial WINPROPS.")
 
+;; FIXME this doesn't seem mature yet. Document in manual when it is.
+(defvar image-transform-resize nil
+  "The image resize operation.
+Its value should be one of the following:
+ - nil, meaning no resizing.
+ - `fit-height', meaning to fit the image to the window height.
+ - `fit-width', meaning to fit the image to the window width.
+ - A number, which is a scale factor (the default size is 1).")
+
+(defvar image-transform-scale 1.0
+  "The scale factor of the image being displayed.")
+
+(defvar image-transform-rotation 0.0
+  "Rotation angle for the image in the current Image mode buffer.")
+
+(defvar image-transform-right-angle-fudge 0.0001
+  "Snap distance to a multiple of a right angle.
+There's no deep theory behind the default value, it should just
+be somewhat larger than ImageMagick's MagickEpsilon.")
+
 (defun image-mode-winprops (&optional window cleanup)
   "Return winprops of WINDOW.
 A winprops object has the shape (WINDOW . ALIST).
@@ -642,14 +662,19 @@ was inserted."
                           (string-make-unibyte
                            (buffer-substring-no-properties (point-min) (point-max)))
                         filename))
-        (edges (window-inside-pixel-edges
-                (get-buffer-window (current-buffer))))
+        ;; If we have a `fit-width' or a `fit-height', don't limit
+        ;; the size of the image to the window size.
+        (edges (and (null image-transform-resize)
+                    (window-inside-pixel-edges
+                     (get-buffer-window (current-buffer)))))
         (type (if (fboundp 'imagemagick-types)
                   'imagemagick
                 (image-type file-or-data nil data-p)))
-        (image (create-image file-or-data type data-p
-                             :max-width (- (nth 2 edges) (nth 0 edges))
-                             :max-height (- (nth 3 edges) (nth 1 edges))))
+        (image (if (not edges)
+                   (create-image file-or-data type data-p)
+                 (create-image file-or-data type data-p
+                               :max-width (- (nth 2 edges) (nth 0 edges))
+                               :max-height (- (nth 3 edges) (nth 1 edges)))))
         (inhibit-read-only t)
         (buffer-undo-list t)
         (modified (buffer-modified-p))
@@ -900,26 +925,6 @@ replacing the current Image mode buffer."
 ;;   nil "image-transform" image-transform-minor-mode-map)
 
 
-;; FIXME this doesn't seem mature yet. Document in manual when it is.
-(defvar image-transform-resize nil
-  "The image resize operation.
-Its value should be one of the following:
- - nil, meaning no resizing.
- - `fit-height', meaning to fit the image to the window height.
- - `fit-width', meaning to fit the image to the window width.
- - A number, which is a scale factor (the default size is 1).")
-
-(defvar image-transform-scale 1.0
-  "The scale factor of the image being displayed.")
-
-(defvar image-transform-rotation 0.0
-  "Rotation angle for the image in the current Image mode buffer.")
-
-(defvar image-transform-right-angle-fudge 0.0001
-  "Snap distance to a multiple of a right angle.
-There's no deep theory behind the default value, it should just
-be somewhat larger than ImageMagick's MagickEpsilon.")
-
 (defsubst image-transform-width (width height)
   "Return the bounding box width of a rotated WIDTH x HEIGHT rectangle.
 The rotation angle is the value of `image-transform-rotation' in degrees."