unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: E Sabof <esabof@gmail.com>
To: Tassilo Horn <tsdh@gnu.org>
Cc: 13887@debbugs.gnu.org
Subject: bug#13887: 24.3; doc-view will render blurry images when image-magick is available
Date: Thu, 14 Mar 2013 15:23:41 +0000	[thread overview]
Message-ID: <CAEp6Dyb57BfRPznrOVycOuFQ-EZQdowa1jXzoi7NmR57bRhFOQ@mail.gmail.com> (raw)
In-Reply-To: <87ip4ue95q.fsf@thinkpad.tsdh.de>

[-- Attachment #1: Type: text/plain, Size: 3536 bytes --]

With this patch I don't get an overlay in the initial window, and sometimes
after splitting. Redefining image-get-display-property as in my previous
patch fixes the splitting problem.

Evgeni


On Thu, Mar 14, 2013 at 7:24 AM, Tassilo Horn <tsdh@gnu.org> wrote:

> E Sabof <esabof@gmail.com> writes:
>
> > The first time (doc-view-insert-image) is called, the doc-view buffer
> > isn't selected, and (doc-view-current-overlay) returns the t overlay.
> >
> > The "fake" overlay gets "resurrected" when (doc-view-insert-image)
> > calls (move-overlay) on it.
>
> Thanks Evgeni, I think that brought me on track.  Could you please
> test-drive this patch (which also contains the centering stuff) and
> check if the issue is fixed by it?  It seems it is for me, but I only
> did some very brief testing.
>
> --8<---------------cut here---------------start------------->8---
> === modified file 'lisp/doc-view.el'
> --- lisp/doc-view.el    2013-02-28 04:02:36 +0000
> +++ lisp/doc-view.el    2013-03-14 07:21:18 +0000
> @@ -1250,17 +1250,33 @@
>    (when doc-view-pending-cache-flush
>      (clear-image-cache)
>      (setq doc-view-pending-cache-flush nil))
> -  (let ((ol (doc-view-current-overlay))
> -        (image (if (and file (file-readable-p file))
> +  (let ((ol (doc-view-current-overlay)))
> +    ;; ol might be a deleted (see `doc-view-new-window-function'), in
> +    ;; which case we don't want to modify it.
> +    (when (overlay-buffer ol)
> +      (let* ((image (if (and file (file-readable-p file))
>                    (if (not (and doc-view-scale-internally
>                                   (fboundp 'imagemagick-types)))
>                        (apply 'create-image file doc-view--image-type nil
> args)
>                      (unless (member :width args)
>                        (setq args `(,@args :width ,doc-view-image-width)))
>                      (apply 'create-image file 'imagemagick nil args))))
> -        (slice (doc-view-current-slice)))
> +            (slice (doc-view-current-slice))
> +            (img-width (and image (car (image-size image))))
> +            (displayed-img-width (if (and image slice)
> +                                     (* (/ (float (nth 2 slice))
> +                                           (car (image-size image
> 'pixels)))
> +                                        img-width)
> +                                   img-width))
> +            (window-width (window-width (selected-window))))
>      (setf (doc-view-current-image) 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 (and image (> window-width displayed-img-width))
> +                      (propertize " " 'display
> +                                  `(space :align-to (+ center (-0.5 .
> ,displayed-img-width))))))
>      (overlay-put ol 'display
>                   (cond
>                    (image
> @@ -1287,7 +1303,7 @@
>                (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)))))))
> +             (if vscroll (set-window-vscroll win vscroll)))))))))
>
>  (defun doc-view-sort (a b)
>    "Return non-nil if A should be sorted before B.
> --8<---------------cut here---------------end--------------->8---
>
> Bye,
> Tassilo
>

[-- Attachment #2: Type: text/html, Size: 4674 bytes --]

  reply	other threads:[~2013-03-14 15:23 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06  3:40 bug#13887: 24.3; doc-view will render blurry images when image-magick is available E Sabof
2013-03-06  8:05 ` Tassilo Horn
2013-03-06 12:13   ` E Sabof
2013-03-06 13:01     ` Tassilo Horn
2013-03-06 14:19       ` E Sabof
2013-03-06 19:43         ` Tassilo Horn
2013-03-07 15:17           ` E Sabof
2013-03-07 15:55             ` Tassilo Horn
2013-03-07 16:15               ` E Sabof
2013-03-07 22:57                 ` E Sabof
2013-03-08  7:57                   ` Tassilo Horn
     [not found]                     ` <CAEp6DybMJkagHjRaXPiA_ED_dntOk=5USr+P9DfqRPZ_JrrKww@mail.gmail.com>
2013-03-09  7:25                       ` bug#13887: Fwd: " E Sabof
2013-03-09  7:26                         ` E Sabof
2013-03-11  9:11                           ` Tassilo Horn
2013-03-11 16:57                             ` Eli Zaretskii
2013-03-11 18:20                               ` Tassilo Horn
2013-03-11 18:45                                 ` Eli Zaretskii
2013-03-11 20:27                                   ` Tassilo Horn
2013-03-11 20:59                                     ` Eli Zaretskii
2013-03-11 22:08                                       ` E Sabof
2013-03-11 23:41                                         ` E Sabof
2013-03-12  1:00                                           ` E Sabof
2013-03-12  8:09                                             ` Tassilo Horn
2013-03-12 16:50                                               ` Eli Zaretskii
2013-03-12 18:00                                                 ` Tassilo Horn
2013-03-12 16:52                                             ` Eli Zaretskii
2013-03-12 17:46                                               ` E Sabof
2013-03-12 21:11                                                 ` Eli Zaretskii
2013-03-14  3:28                                                   ` E Sabof
2013-03-14  3:56                                                     ` E Sabof
2013-03-14  7:24                                                     ` Tassilo Horn
2013-03-14 15:23                                                       ` E Sabof [this message]
2013-03-14 16:48                                                         ` Tassilo Horn
2013-03-14 21:42                                                           ` Tassilo Horn
2013-03-15  1:11                                                             ` E Sabof
2013-03-15 12:52                                                               ` Stefan Monnier
2013-03-15 13:34                                                                 ` E Sabof
2013-03-15 17:51                                                                   ` Stefan Monnier
2013-03-15 23:26                                                                     ` E Sabof
2013-03-16 13:41                                                                       ` Stefan Monnier
2013-03-16 23:30                                                                         ` E Sabof
2013-03-15 13:55                                                               ` Tassilo Horn
2013-03-15 14:08                                                                 ` E Sabof
2013-03-20 15:58                                                                 ` E Sabof
2019-09-26 17:16                                                                   ` Lars Ingebrigtsen
2019-10-14  6:04                                                                     ` Lars Ingebrigtsen
2013-03-14 13:26                                                     ` Stefan Monnier
2013-03-14 15:30                                                       ` Tassilo Horn
2013-03-14 15:53                                                         ` E Sabof
2013-03-14 16:19                                                         ` Stefan Monnier
2013-03-06 18:16 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEp6Dyb57BfRPznrOVycOuFQ-EZQdowa1jXzoi7NmR57bRhFOQ@mail.gmail.com \
    --to=esabof@gmail.com \
    --cc=13887@debbugs.gnu.org \
    --cc=tsdh@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).