From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: E Sabof Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <87txonw6ev.fsf@thinkpad.tsdh.de> <87sj46493q.fsf@thinkpad.tsdh.de> <877gle1etb.fsf@thinkpad.tsdh.de> <838v5tx4av.fsf@gnu.org> <87txohx0g0.fsf@thinkpad.tsdh.de> <831ubllqr0.fsf@gnu.org> <87zjy9vg0r.fsf@thinkpad.tsdh.de> <83y5dtk606.fsf@gnu.org> <83li9sk1bh.fsf@gnu.org> <83hakgjpbi.fsf@gnu.org> <87ip4ue95q.fsf@thinkpad.tsdh.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=20cf30050e8a8cb95104d7e41bd6 X-Trace: ger.gmane.org 1363274706 4482 80.91.229.3 (14 Mar 2013 15:25:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Mar 2013 15:25:06 +0000 (UTC) Cc: 13887@debbugs.gnu.org To: Tassilo Horn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Mar 14 16:25:31 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UGA25-0000ZB-Sh for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Mar 2013 16:25:30 +0100 Original-Received: from localhost ([::1]:59391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGA1j-0002tH-40 for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Mar 2013 11:25:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGA1Z-0002gn-Mt for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2013 11:25:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGA1S-0002cP-UY for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2013 11:24:57 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50120) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGA1S-0002cL-Rk for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2013 11:24:50 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UGA2c-0003vQ-Cs for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2013 11:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: E Sabof Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Mar 2013 15:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13887 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13887-submit@debbugs.gnu.org id=B13887.136327471015022 (code B ref 13887); Thu, 14 Mar 2013 15:26:02 +0000 Original-Received: (at 13887) by debbugs.gnu.org; 14 Mar 2013 15:25:10 +0000 Original-Received: from localhost ([127.0.0.1]:54229 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UGA1h-0003uA-8H for submit@debbugs.gnu.org; Thu, 14 Mar 2013 11:25:10 -0400 Original-Received: from mail-qe0-f46.google.com ([209.85.128.46]:59403) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UGA1a-0003tY-Jp for 13887@debbugs.gnu.org; Thu, 14 Mar 2013 11:25:04 -0400 Original-Received: by mail-qe0-f46.google.com with SMTP id a11so1337317qen.33 for <13887@debbugs.gnu.org>; Thu, 14 Mar 2013 08:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=RWLnrbVDjTQG2qluhyxnQcfNJj9wCfBf3Bq5v0HPNeo=; b=YJKJPPNxpKG6ZMvXkdUNLn4IMRrpj7bvqpd1cC239NYFB4dxZdqSsXTtY74YcZWtz6 JMOTCO0+eUfCtwU0hya7BsokW6jFw0eG5ehruPTs4R9Wy3PpKW7QtQGG3dRy7+HqvHHj g4owwuzCD9Sicy87qeY7afvdRGGGbIfXCDteK91zH3P+CHQa0Sb1PMFqh46CNGuqZZJr BzRx9j3nueXuaQISQtbNKke2QwXyMnt0Lyc4M7UNwLallPm3TMBQdEwA47w7vNyUvVMp WWJLD2vjdFAm/JDUJkSsGcELjTJ10FpqL28VkKp8qaWUGEk5XecBPnZ9dSoqhDi2skik r5tQ== X-Received: by 10.224.199.70 with SMTP id er6mr3560200qab.19.1363274621563; Thu, 14 Mar 2013 08:23:41 -0700 (PDT) Original-Received: by 10.49.70.233 with HTTP; Thu, 14 Mar 2013 08:23:41 -0700 (PDT) In-Reply-To: <87ip4ue95q.fsf@thinkpad.tsdh.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:72471 Archived-At: --20cf30050e8a8cb95104d7e41bd6 Content-Type: text/plain; charset=ISO-8859-1 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 wrote: > E Sabof 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 > --20cf30050e8a8cb95104d7e41bd6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
With=A0this patch I don't get an overlay in the initia= l window, and sometimes after splitting. Redefining=A0image-get-display-pr= operty 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@gm= ail.com> writes:

> The first time (doc-view-insert-image) is called, the doc-view buffer<= br> > isn't selected, and (doc-view-current-overlay) returns the t overl= ay.
>
> The "fake" overlay gets "resurrected" when (doc-vi= ew-insert-image)
> calls (move-overlay) on it.

Thanks Evgeni, I think that brought me on track. =A0Could you please<= br> test-drive this patch (which also contains the centering stuff) and
check if the issue is fixed by it? =A0It seems it is for me, but I only
did some very brief testing.

--8<---------------cut here---------------start------------->8---
=3D=3D=3D modified file 'lisp/doc-view.el'
--- lisp/doc-view.el =A0 =A02013-02-28 04:02:36 +0000
+++ lisp/doc-view.el =A0 =A02013-03-14 07:21:18 +0000
@@ -1250,17 +1250,33 @@
=A0 =A0(when doc-view-pending-cache-flush
=A0 =A0 =A0(clear-image-cache)
=A0 =A0 =A0(setq doc-view-pending-cache-flush nil))
- =A0(let ((ol (doc-view-current-overlay))
- =A0 =A0 =A0 =A0(image (if (and file (file-readable-p file))
+ =A0(let ((ol (doc-view-current-overlay)))
+ =A0 =A0;; ol might be a deleted (see `doc-view-new-window-function'),= in
+ =A0 =A0;; which case we don't want to modify it.
+ =A0 =A0(when (overlay-buffer ol)
+ =A0 =A0 =A0(let* ((image (if (and file (file-readable-p file))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(if (not (and doc-= view-scale-internally
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (fbound= p 'imagemagick-types)))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(app= ly 'create-image file doc-view--image-type nil args)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(unless = (member :width args)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(setq args `(,@args :width ,= doc-view-image-width)))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(apply 'create-image file &#= 39;imagemagick nil args))))
- =A0 =A0 =A0 =A0(slice (doc-view-current-slice)))
+ =A0 =A0 =A0 =A0 =A0 =A0(slice (doc-view-current-slice))
+ =A0 =A0 =A0 =A0 =A0 =A0(img-width (and image (car (image-size image)))) + =A0 =A0 =A0 =A0 =A0 =A0(displayed-img-width (if (and image slice)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (= * (/ (float (nth 2 slice))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 (car (image-size image 'pixels)))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0img-width)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 img-w= idth))
+ =A0 =A0 =A0 =A0 =A0 =A0(window-width (window-width (selected-window)))) =A0 =A0 =A0(setf (doc-view-current-image) image)
=A0 =A0 =A0(move-overlay ol (point-min) (point-max))
+ =A0 =A0 =A0 ;; In case the window is wider than the image, center t= he image
+ =A0 =A0 =A0 ;; horizontally.
+ =A0 =A0 =A0 (overlay-put ol 'before-string
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(when (and image (> window-widt= h displayed-img-width))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(propertize " " '= ;display
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0`(spac= e :align-to (+ center (-0.5 . ,displayed-img-width))))))
=A0 =A0 =A0(overlay-put ol 'display
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (cond
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(image
@@ -1287,7 +1303,7 @@
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(vscroll (image-mode-window-get 'vscroll= win)))
=A0 =A0 =A0 =A0 =A0 =A0;; Reset scroll settings, in case they were changed.=
=A0 =A0 =A0 =A0 =A0 =A0(if hscroll (set-window-hscroll win hscroll))
- =A0 =A0 =A0 =A0 =A0(if vscroll (set-window-vscroll win vscroll)))))))
+ =A0 =A0 =A0 =A0 =A0 =A0 (if vscroll (set-window-vscroll win vscroll))))))= )))

=A0(defun doc-view-sort (a b)
=A0 =A0"Return non-nil if A should be sorted before B.
--8<---------------cut here-----= ----------end--------------->8---

Bye,
Tassilo

--20cf30050e8a8cb95104d7e41bd6--