GNU bug report logs -
#6639
24.0.50; [PATCH]image-mode: Sliced Images cannot be scrolled up
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6639 in the body.
You can then email your comments to 6639 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6639
; Package
emacs
.
(Thu, 15 Jul 2010 13:38:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
shyam <at> swathanthran.in (Shyam | ശ്യാം കാരനാട്ട് | Karanatt)
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 15 Jul 2010 13:38:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
trying to scroll up a sliced image, shows an error,
"image-next-line: Invalid image specification"
Steps to reproduce the error:
1)Open a pdf file in doc-view mode, and slice the image by pressing
"s s"( i.e doc-view-set-slice), and giving the parameters.
2)scroll the page with C-n or image-next-line or image-scroll-up
That shows the error message
"image-next-line: Invalid image specification"
OR
1)open an image file "~/test-image.png", or insert an image file to a buffer with:
(insert-image (create-image "~/test-image.png")).
2) set, slice property for the image with add-text-properties function,
for example:
(let ((inhibit-read-only t)
(X 50)
(Y 50)
(WIDTH 300)
(HEIGHT 300))
(add-text-properties
(point-min)
(point-max)
`(display (,(list 'slice X Y WIDTH HEIGHT)
(image :type png :file "~/test-image.png")))))
3)Scroll up the image by pressing C-n(i.e image-next-line) or M-x image-scroll-up
that shows the following messages:
image-next-line: Invalid image specification
Or with (setq debug-on-error t) you get this:
Debugger entered--Lisp error: (error "Invalid image specification")
image-size(((slice 50 50 300 300) (image :type png :file "~/page-15.png")))
image-next-line(1)
call-interactively(image-next-line nil nil)
image-next-line in image-mode.el is relying on function image-size,
which is to be fed with the image display property of the form (image
...). But if the image is sliced, it will have (slice ..) display
property attached, which image-next-line is not taking care of. The
patch attached, checks if it is a an image property. If there is slice
property, it takes the image height from the slice property instead. It
also won't mind having other display properties than image and slice too
to be included on display properties, as it assoc's the value of image
and slice.
I saw the bug while reading ebooks on doc-view with margins sliced out.
Happy Hacking
Shyam K
In GNU Emacs 24.0.50.2 (i686-pc-linux-gnu, GTK+ Version 2.20.1)
of 2010-06-01 on shyam.laptop
Windowing system distributor `The X.Org Foundation', version 11.0.10801902
configured using `configure '--prefix=/usr/''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: nil
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
[image-mode_image-next-line.patch (text/x-patch, inline)]
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: shyam <at> swathanthran.in-20100715075217-cvwlhocdru9xcxkh
# author: Shyam Karanatt<shyam <at> swathanthran.in>
# target_branch: file:///media/sda5/home/shyam/bazaar-\
# emacs/emacs/clean-trunk/
# testament_sha1: d49bcb73c9113f671bfbafd26c333a809b85cbec
# timestamp: 2010-07-15 13:29:40 +0530
# base_revision_id: yamaoka <at> jpl.org-20100715005613-1hdb4741v79szq8v
#
# Begin patch
=== modified file 'lisp/image-mode.el'
--- lisp/image-mode.el 2010-07-14 15:57:54 +0000
+++ lisp/image-mode.el 2010-07-15 07:52:17 +0000
@@ -157,9 +157,15 @@
((< n 0)
(image-set-window-vscroll (max 0 (+ (window-vscroll) n))))
(t
- (let* ((image (image-get-display-property))
+ (let* ((image-display (image-get-display-property))
+ (image (if (eq (car image-display) 'image)
+ image-display
+ (assoc 'image image-display)))
+ (slice (assoc 'slice image-display))
(edges (window-inside-edges))
(win-height (- (nth 3 edges) (nth 1 edges)))
- (img-height (ceiling (cdr (image-size image)))))
+ (img-height (if slice
+ (nth 4 slice)
+ (ceiling (cdr (image-size image))))))
(image-set-window-vscroll (min (max 0 (- img-height win-height))
(+ n (window-vscroll))))))))
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6639
; Package
emacs
.
(Fri, 16 Jul 2010 13:57:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 6639 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I forgot to look for other calls to image-size. Looking through the
whole emacs code, only image-mode seems to be making calls to
image-size, which can possibly be including slice property.
So Now, I wrote a wrapper over image-size function which calculates size
From slice property if available, or calls image-size if, only image
property is available.
The patch is attached.
Happy Hacking
Shyam K
[image-mode_image-display-size.patch (text/x-patch, inline)]
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: shyam <at> swathanthran.in-20100716100307-6y92sw2p0xmgd7mj
# author: Shyam Karanatt <shyam <at> swathanthran.in>
# testament_sha1: 71e9837d7961814d5fcb0f63955e2485584ea1e7
# timestamp: 2010-07-16 16:32:50 +0530
# base_revision_id: yamaoka <at> jpl.org-20100715005613-1hdb4741v79szq8v
#
# Begin patch
=== modified file 'lisp/image-mode.el'
--- lisp/image-mode.el 2010-07-14 15:57:54 +0000
+++ lisp/image-mode.el 2010-07-16 10:03:07 +0000
@@ -128,6 +128,28 @@
(declare-function image-size "image.c" (spec &optional pixels frame))
+(defun image-display-size (spec &optional pixels frame)
+"Wrapper around image-size to considers \(slice ..\) display property in SPEC.
+If SPEC is an image display property, call `image-size' with arguments.
+If SPEC is list of properties having image and slice properties in it,
+calculate size from slice.
+If slice is not in the list but image is, call `image-size' with image.
+If SPEC is a list without having image display property in it,
+ error about invalid image specification."
+ (if (eq (car spec) 'image)
+ (image-size spec pixels frame)
+ (let ((image (assoc 'image spec))
+ (slice (assoc 'slice spec)))
+ (cond ((and image slice)
+ (if pixels
+ (cons (nth 3 slice) (nth 4 slice))
+ (cons (/ (float (nth 3 slice)) (frame-char-width frame))
+ (/ (float (nth 4 slice)) (frame-char-height frame)))))
+ (image
+ (image-size image pixels frame))
+ (t
+ (error "Invalid image specification: %s" spec))))))
+
(defun image-forward-hscroll (&optional n)
"Scroll image in current window to the left by N character widths.
Stop if the right edge of the image is reached."
@@ -139,7 +161,7 @@
(let* ((image (image-get-display-property))
(edges (window-inside-edges))
(win-width (- (nth 2 edges) (nth 0 edges)))
- (img-width (ceiling (car (image-size image)))))
+ (img-width (ceiling (car (image-display-size image)))))
(image-set-window-hscroll (min (max 0 (- img-width win-width))
(+ n (window-hscroll))))))))
@@ -160,7 +182,7 @@
(let* ((image (image-get-display-property))
(edges (window-inside-edges))
(win-height (- (nth 3 edges) (nth 1 edges)))
- (img-height (ceiling (cdr (image-size image)))))
+ (img-height (ceiling (cdr (image-display-size image)))))
(image-set-window-vscroll (min (max 0 (- img-height win-height))
(+ n (window-vscroll))))))))
@@ -233,7 +255,7 @@
(let* ((image (image-get-display-property))
(edges (window-inside-edges))
(win-width (- (nth 2 edges) (nth 0 edges)))
- (img-width (ceiling (car (image-size image)))))
+ (img-width (ceiling (car (image-display-size image)))))
(image-set-window-hscroll (max 0 (- img-width win-width)))))
(defun image-bob ()
@@ -248,9 +270,9 @@
(let* ((image (image-get-display-property))
(edges (window-inside-edges))
(win-width (- (nth 2 edges) (nth 0 edges)))
- (img-width (ceiling (car (image-size image))))
+ (img-width (ceiling (car (image-display-size image))))
(win-height (- (nth 3 edges) (nth 1 edges)))
- (img-height (ceiling (cdr (image-size image)))))
+ (img-height (ceiling (cdr (image-display-size image)))))
(image-set-window-hscroll (max 0 (- img-width win-width)))
(image-set-window-vscroll (max 0 (- img-height win-height)))))
@@ -264,7 +286,7 @@
(interactive)
(let* ((saved (frame-parameter nil 'image-mode-saved-size))
(display (image-get-display-property))
- (size (image-size display)))
+ (size (image-display-size display)))
(if (and saved
(eq (caar saved) (frame-width))
(eq (cdar saved) (frame-height)))
[Message part 3 (application/pgp-signature, inline)]
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6639
; Package
emacs
.
(Sat, 17 Jul 2010 21:52:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 6639 <at> debbugs.gnu.org (full text, mbox):
shyam <at> swathanthran.in (Shyam | ശ്യാം കാരനാട്ട് | Karanatt) writes:
> I forgot to look for other calls to image-size. Looking through the
> whole emacs code, only image-mode seems to be making calls to
> image-size, which can possibly be including slice property.
>
> So Now, I wrote a wrapper over image-size function which calculates size
> From slice property if available, or calls image-size if, only image
> property is available.
>
> The patch is attached.
Thanks. I have committed your patch to the emacs-23 branch.
bug closed, send any further explanations to shyam <at> swathanthran.in (Shyam | ശ്യാം കാരനാട്ട് | Karanatt)
Request was from
Chong Yidong <cyd <at> stupidchicken.com>
to
control <at> debbugs.gnu.org
.
(Sat, 17 Jul 2010 21:52:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 15 Aug 2010 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 14 years and 307 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.