all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
To: 6639@debbugs.gnu.org
Subject: bug#6639: [PATCH]image-mode: making image-mode functions to consider slice property
Date: Fri, 16 Jul 2010 17:01:28 +0530	[thread overview]
Message-ID: <87eif3hddb.fsf@shyam.laptop> (raw)
In-Reply-To: <87r5j5ruzq.fsf@shyam.laptop>


[-- Attachment #1.1: Type: text/plain, Size: 417 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: patch for making image-mode functions to consider slice property --]
[-- Type: text/x-patch, Size: 3790 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: shyam@swathanthran.in-20100716100307-6y92sw2p0xmgd7mj
# author: Shyam Karanatt <shyam@swathanthran.in>
# testament_sha1: 71e9837d7961814d5fcb0f63955e2485584ea1e7
# timestamp: 2010-07-16 16:32:50 +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-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)))


[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]

      reply	other threads:[~2010-07-16 11:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-15  8:48 bug#6639: 24.0.50; [PATCH]image-mode: Sliced Images cannot be scrolled up 
2010-07-16 11:31 `  [this message]

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=87eif3hddb.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.