[mew-dist 27299] Re: 大きな写真

Hideyuki SHIRAI ( 白井秀行 ) shirai at example.com
2006年 9月 7日 (木) 19:16:39 JST


白井です。

From: Koyama Mituru <mew at example.com> さん曰く
Subject: [mew-dist 27298] Re: 大きな写真
Message-ID: <20060907.183858.78705994.mew at example.com>
Date: Thu, 07 Sep 2006 18:38:58 +0900 (JST)

> > このパッチで、小山さんの PNG 問題も直りますか?
> 
>  (setq mew-image-display-resize t)にして、640x480のjpg画像を選択。
> 以前と同様、表示に10秒以上かかる。

どこで時間がかかっているのわからないと、どうしようもなさそうなの
で試験してみませんか?

mew-mime-image() を以下で置き換えて、メールの画像を表示した後、
"M-x my-time-calc" とするとそれぞれの期間でかかった秒数が出ます
ので、参考にはなるかと。

# 実際に試したわけではないので、どこかで間違っていたらごめんなさ
# い。

(defun mew-mime-image (cache begin end format)
  (message "Loading image...")
  (set-buffer (mew-buffer-message))
  (let* ((width (- (frame-pixel-width (selected-frame)) mew-image-width-margin))
	 (height (- (frame-pixel-height (selected-frame)) mew-image-height-margin))
	 (ent (mew-image-format-ent format))
	 (prog (mew-image-get-prog ent))
	 (func-size (mew-image-get-func ent))
	 image-width image-height image)
    (setq my-time1 (current-time))
    (when (and mew-image-display-resize func-size (fboundp func-size))
      (save-excursion
	(set-buffer cache)
	(goto-char begin)
	(setq image-width (car (funcall func-size)))
	(setq image-height (cdr (funcall func-size)))))
    (if (and image-width image-height
	     (or (< width image-width)
		 (and mew-image-display-resize-care-height (< height image-height)))
	     (mew-which-exec prog))
	(with-temp-buffer
	  (mew-plet
	   (message "Resizing image...")
	   (insert-buffer-substring cache begin end)
	   (mew-set-buffer-multibyte nil)
	   (setq my-time2 (current-time))
	   (call-process-region (point-min) (point-max) prog
				t '(t nil) nil)
	   (setq my-time3 (current-time))
	   (if mew-image-display-resize-care-height
	       (call-process-region (point-min) (point-max) "pnmscale"
				    t '(t nil) nil
				    "-xysize"
				    (format "%d" width)
				    (format "%d" height))
	     (call-process-region (point-min) (point-max) "pnmscale"
				  t '(t nil) nil
				  "-xsize"	(format "%d" width)))
	   (setq my-time4 (current-time))
	   (setq format 'pbm)
	   (setq image (mew-buffer-substring (point-min) (point-max)))
	   (message "Resizing image...done")))
      (save-excursion
	(set-buffer cache)
	(setq image (mew-buffer-substring begin end))))
    (setq my-time5 (current-time))
    (mew-elet
     (condition-case nil
	 (insert-image
	  (prog1
	      (create-image
	       (prog1
		   (string-as-unibyte image)
		 (setq my-time6 (current-time)))
	       format t)
	    (setq my-time7 (current-time))))
       (error ()))))
  (setq my-time8 (current-time))
  (goto-char (point-min))
  (message "Loading image...done"))

(defun my-time-calc ()
  (interactive)
  (let ((t8 (mew-time-calc my-time8 my-time7))
	(t7 (mew-time-calc my-time7 my-time6))
	(t6 (mew-time-calc my-time6 my-time5))
	(t5 (mew-time-calc my-time5 my-time4))
	(t4 (mew-time-calc my-time4 my-time3))
	(t3 (mew-time-calc my-time3 my-time2))
	(t2 (mew-time-calc my-time2 my-time1))
	(buf (get-buffer-create "*tmp*")))
    (pop-to-buffer buf)
    (insert (format "t2: %f\nt3: %f\nt4: %f\nt5: %f\nt6: %f\nt7: %f\nt8: %f\n"
		    t2 t3 t4 t5 t6 t7 t8))))

-- 
白井秀行 (mailto:shirai at example.com)



Mew-dist メーリングリストの案内