emacs-framebuffer

Emacs library to show images and documents in console using Linux framebuffer
Log | Files | Refs

commit 35e81278c9c9049a91ee529fa1fdbce8bc64b4ae
parent 07ff446574552a2fac29d344766178712b8e3aa9
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 24 May 2020 15:49:47 +0200

support tiff

Diffstat:
Memacs-framebuffer.el | 34++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/emacs-framebuffer.el b/emacs-framebuffer.el @@ -88,8 +88,9 @@ (with-temp-buffer (set-buffer-multibyte nil) (insert-file-contents-literally file) - (let ((brook (framebuffer-buffer-brook))) - (case (funcall brook) + (let* ((brook (framebuffer-buffer-brook)) + (a (framebuffer-next-u8 brook))) + (case a (137 ;; png (when (and (= ?P (funcall brook)) (= ?N (funcall brook)) @@ -132,6 +133,30 @@ (= ?a (framebuffer-next-u8 brook))) (cons (framebuffer-next-u16le brook) (framebuffer-next-u16le brook)))) + ((?I ?M) ;; tiff + (let ((b (framebuffer-next-u8 brook))) + (when (= a b) + (multiple-value-bind (u16 u32) + (ecase a + (?I (values 'framebuffer-next-u16le 'framebuffer-next-u32le)) + (?M (values 'framebuffer-next-u16 'framebuffer-next-u32))) + (when (= #x2a (funcall u16 brook)) + (let (w h) + (goto-char (1+ (funcall u32 brook))) + (dotimes (i (funcall u16 brook)) + (let ((tag (funcall u16 brook)) + (type (funcall u16 brook)) + (n (funcall u32 brook)) + (v (funcall u32 brook))) + (case tag + (#x0100 + (ecase type + (3 (setq w v)))) + (#x0101 + (ecase type + (3 (setq h v))))))) + (when (and w h) + (cons w h)))))))) )))) (defun framebuffer-image-file (file) @@ -154,8 +179,9 @@ (defun framebuffer-dired-image-p () (let ((f (dired-file-name-at-point))) (and (not (file-directory-p f)) - (string-match "jpe?g\\|JPE?G\\|png\\|PNG\\|bmp\\|BMP\\|gif\\|GIF" - (file-name-extension f))))) + (string-match + "jpe?g\\|JPE?G\\|png\\|PNG\\|bmp\\|BMP\\|gif\\|GIF\\|tiff?\\|TIFF?" + (file-name-extension f))))) (defun framebuffer-image-file-dired-next (arg) (interactive "^p")