all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
To: 6639@debbugs.gnu.org
Subject: bug#6639: 24.0.50; [PATCH]image-mode: Sliced Images cannot be scrolled up
Date: Thu, 15 Jul 2010 14:18:25 +0530	[thread overview]
Message-ID: <87r5j5ruzq.fsf@shyam.laptop> (raw)

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


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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch for image-mode.el --]
[-- Type: text/x-patch, Size: 1248 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: shyam@swathanthran.in-20100715075217-cvwlhocdru9xcxkh
# author: Shyam Karanatt<shyam@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@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))))))))

             reply	other threads:[~2010-07-15  8:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-15  8:48  [this message]
2010-07-16 11:31 ` bug#6639: [PATCH]image-mode: making image-mode functions to consider slice property 

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

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

  git send-email \
    --in-reply-to=87r5j5ruzq.fsf@shyam.laptop \
    --to=6639@debbugs.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.