Function: pdf-view-display-image

pdf-view-display-image is a natively compiled function defined in pdf-view.el.

Signature

(pdf-view-display-image IMAGE PAGE &optional WINDOW INHIBIT-SLICE-P)

Source Code

;; Defined in /nix/store/63h5z2vmzn0mfavcxi2idi23g5xcgkbl-emacs-packages-deps/share/emacs/site-lisp/elpa/pdf-tools-20260102.1101/pdf-view.el
(defun pdf-view-display-image (image page &optional window inhibit-slice-p)
  ;; TODO: write documentation!
  (if pdf-view-roll-minor-mode
      (pdf-roll-display-image
       image page (or window (selected-window)) inhibit-slice-p)
    (let ((ol (pdf-view-current-overlay window)))
      (when (window-live-p (overlay-get ol 'window))
        (let* ((size (image-size image t))
               (slice (if (not inhibit-slice-p)
                          (pdf-view-current-slice window)))
               (displayed-width (floor
                                 (if slice
                                     (* (nth 2 slice)
                                        (car (image-size image)))
                                   (car (image-size image))))))
          (setf (pdf-view-current-image window) image)
          (move-overlay ol (point-min) (point-max))
          ;; In case the window is wider than the image, center the image
          ;; horizontally.
          (overlay-put ol 'before-string
                       (when (> (window-width window)
                                displayed-width)
                         (propertize " " 'display
                                     `(space :align-to
                                       ,(/ (- (window-width window)
                                              displayed-width) 2)))))
          (overlay-put ol 'display
                       (if slice
                           (list (cons 'slice
                                       (pdf-util-scale slice size 'round))
                                 image)
                         image))
          (let* ((win (overlay-get ol 'window))
                 (hscroll (image-mode-window-get 'hscroll win))
                 (vscroll (image-mode-window-get 'vscroll win)))
            ;; Reset scroll settings, in case they were changed.
            (if hscroll (set-window-hscroll win hscroll))
            (if vscroll (set-window-vscroll
                         win vscroll pdf-view-have-image-mode-pixel-vscroll))))))))