annotate lisp/tl/bitmap.el @ 4:b82b59fe008d r19-15b3

Import from CVS: tag r19-15b3
author cvs
date Mon, 13 Aug 2007 08:46:56 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1 ;; bitmap.el -- bitmap (xbm) file handler on Mule
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992 Electrotechnical Laboratory, JAPAN.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
4 ;; Copyright (C) 1996 UENO Hiroshi
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
5 ;; Copyright (C) 1996 MORIOKA Tomohiko
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
6
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
7 ;; Author: Ken'ichi HANDA <handa@etl.go.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
8 ;; Hiroshi Ueno <jl07715@yamato.ibm.co.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
9 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
10 ;; Version:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
11 ;; $Id: bitmap.el,v 1.1.1.1 1996/12/18 03:55:31 steve Exp $
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
12 ;; Keywords: bitmap, xbm, X-Face, Mule
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
13
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
14 ;; This file is part of tl (Tiny Library).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
15
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
16 ;; This program is free software; you can redistribute it and/or modify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
17 ;; it under the terms of the GNU General Public License as published by
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
18 ;; the Free Software Foundation; either version 2, or (at your option)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
19 ;; any later version.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
20
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
21 ;; This program is distributed in the hope that it will be useful,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
24 ;; GNU General Public License for more details.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
25
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
26 ;; You should have received a copy of the GNU General Public License
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
27 ;; along with this program; if not, write to the Free Software
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
28 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
30 ;; Code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
31
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
32 (require 'tl-822)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
33
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
34 (defvar lc-bitmap
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
35 (new-private-character-set 2 1 3 0 ?0 0 "BITMAP 8x16" "bitmap")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
36 "Leading character for BITMAP.8x16.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
37
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
38 (mapcar (lambda (fontset)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
39 (if (= (fontset-pixel-size fontset) 16)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
40 (set-fontset-font
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
41 fontset lc-bitmap
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
42 "-etl-fixed-medium-r-*--16-*-100-100-m-*-bitmap.8x16-0")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
43 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
44 (fontset-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
45
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
46 ;; Block (all bits set) character
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
47 (defvar bitmap-block (make-character lc-bitmap 32 33))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
48
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
49 ;; Simple examples:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
50 ;; (bitmap-compose "00FF00FF00FF00FF00FF00FF00FF00FF")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
51 ;; (bitmap-compose
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
52 ;; "FF00FF00FF00FF00FF00FF00FF00FF00AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
53
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
54 (defun read-hexa (str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55 (let ((result 0) (i 0) (max (length str)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
56 (while (< i max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
57 (let ((ch (aref str i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
58 (cond((and (<= ?0 ch) (<= ch ?9))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
59 (setq result (+ (* result 16) (- ch ?0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
60 ((and (<= ?a ch) (<= ch ?f))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
61 (setq result (+ (* result 16) (+ (- ch ?a) 10))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
62 ((and (<= ?A ch) (<= ch ?F))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
63 (setq result (+ (* result 16) (+ (- ch ?A) 10)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
64 (setq i (1+ i))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
65 result))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
66
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
67 (defun bitmap-compose (hex)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
68 "Return a string of composite characters which represents BITMAP-PATTERN.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
69 BITMAP-PATTERN is a string of hexa decimal for 8x16 dot-pattern.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
70 For example the pattern \"0081814242242442111124244242818100\" is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
71 for a bitmap of shape something like 'X' character."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
72 (let* ((len (/ (length hex) 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
73 (bytes (char-bytes lc-bitmap))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
74 (cmpstr "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
75 (buf (make-string 64 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
76 block-flag i j row code c1 c2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
77 (setq i 0 j 0 block-flag t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
78 (while (< i len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
79 (setq row (read-hexa (substring hex (* i 2) (+ (* i 2) 2))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
80 (if block-flag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
81 (setq block-flag (= row 255)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
82 (if (/= row 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
83 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84 (setq code (+ (* (% i 16) 255) row -1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
85 (setq c1 (+ (/ code 96) 33)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
86 c2 (+ (% code 96) 32))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
87 (sset buf j (make-character lc-bitmap c1 c2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
88 (setq j (+ j bytes))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
89 (setq i (1+ i))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
90 (if (or (= (% i 16) 0) (>= i len))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91 (setq cmpstr
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92 (concat cmpstr
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
93 (if (and block-flag (= j 64))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
94 (char-to-string bitmap-block)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
95 (if (= j 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 " "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
97 (compose-string (substring buf 0 j)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
98 block-flag t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
99 j 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
100 cmpstr))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
101
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
103 ;;; @ BDF
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
104 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106 ;; Internal variables -- declared here to reduce garbage collection.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107 (defconst *hex* (vector (make-string 96 0) (make-string 96 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 (defconst *hex-len* (length *hex*))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
109 (defconst *cmp* (make-vector *hex-len* nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
110
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
111 (defun bdf-to-bitmap (bdf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112 "Set *cmp* a vector of string for BDF.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113 BDF is a vector of string, each elements corresponds to a line of bitmap
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
114 of difinition of a character glyph in bdf file."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
115 (let ((width (length (aref bdf 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116 (height (length bdf))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117 i j)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
118 (if (or (/= (/ (+ height 15) 16) *hex-len*)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 (/= width (length (aref *hex* 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
120 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
121 (setq *hex-len* (/ (+ height 15) 16))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
122 (setq *hex* (make-vector *hex-len* nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
123 (setq *cmp* (make-vector *hex-len* nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124 (setq i 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125 (while (< i *hex-len*)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
126 (aset *hex* i (make-string 96 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
127 (setq i (1+ i)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
128 (setq j 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
129 (while (< j width)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
130 (setq i 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
131 (while (< i (* *hex-len* 16))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
132 (aset (aref *hex* (/ i 16))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
133 (+ (* (/ j 2) 32) (* (% i 16) 2) (% j 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
134 (if (< i height) (aref (aref bdf i) j) 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
135 (setq i (1+ i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
136 (setq j (1+ j)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
137 (setq i 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
138 (while (< i *hex-len*)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
139 (aset *cmp* i (bitmap-compose (aref *hex* i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
140 (setq i (1+ i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
141 *cmp*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
142 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
143
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
144
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
145 ;;; @ XBM
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
146 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
147
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
148 (defun bitmap-show-xbm (buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
149 "Show bitmap in buffer BUF. Very slow! [bitmap.el]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
150 (let ((hexa-string "0123456789ABCDEF")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
151 (reverse-bit '[0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
152 i j w h bitmap cmp c temp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
153 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
154 (set-buffer buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
155 (goto-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
156 (search-forward "width " nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
157 (setq w (read (current-buffer)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
158 (goto-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
159 (search-forward "height " nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
160 (setq h (read (current-buffer)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
161 (search-forward "0x" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
162 (setq bitmap (make-vector h 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
163 (setq cmp (make-vector (/ (+ h 15) 16) nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
164 (setq j 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
165 (setq w (/ (+ w 7) 8))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
166 (while (< j h)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
167 (aset bitmap j (make-vector w 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
168 (setq j (1+ j)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
169 (setq j 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
170 (message "%dx%d" w h)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
171 (while (< j h)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
172 (setq i 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
173 (while (< i w)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
174 (setq temp (buffer-substring (point) (+ (point) 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
175 (aset (aref bitmap j) i temp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
176 (setq c (read-hexa temp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
177 (aset temp 0 (aref hexa-string (aref reverse-bit (% c 16))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
178 (aset temp 1 (aref hexa-string (aref reverse-bit (/ c 16))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
179 (setq i (1+ i))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
180 (search-forward "0x" nil t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
181 (setq j (1+ j)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
182 (message "bitmap translating...")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
183 (setq i 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
184 (while (< i w)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
185 (setq j 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
186 (while (< j h)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
187 (aset cmp (/ j 16)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
188 (concat (aref cmp (/ j 16))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
189 (aref (aref bitmap j) i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
190 (setq j (1+ j)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
191 (if (> (% h 16) 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
192 (aset cmp (/ h 16)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
193 (concat (aref cmp (/ h 16))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
194 (make-string (* (- 16 (% h 16)) 2) ?0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
195 (setq i (1+ i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
196 (message "cmp created"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
197 (setq j 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
198 (while (< j (length cmp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
199 (insert (bitmap-compose (aref cmp j)) ?\n)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
200 ;;(insert (aref cmp j) ?\n)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
201 (setq j (1+ j)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
202
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
203 (defun bitmap-read-xbm (file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
204 "Read .xbm file and show the bitmap.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
205 Very slow! [bitmap.el]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
206 (interactive "fBitmap-file: ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
207 (bitmap-show-xbm (find-file-noselect (expand-file-name file)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
208 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
209
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
210
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
211 ;;; @ X-Face
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
212 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
213
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
214 (defvar bitmap-uncompface-program "uncompface")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
215
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
216 (defun bitmap-decode-x-face ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
217 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
218 (rfc822/narrow-to-header)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
219 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
220 (if (re-search-forward "^X-Face:[ \t]*" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
221 (let ((p (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
222 (beg (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
223 (end (rfc822/field-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
224 (cur-buf (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
225 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
226 (if (< end (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
227 (setq end (1+ end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
228 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
229 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
230 (narrow-to-region p end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
231 (delete-region p beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
232 (call-process-region p (point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
233 bitmap-uncompface-program t t nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
234 (let (i k k+6 cmp temp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
235 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
236 (search-forward "0x" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
237 (setq cmp (make-vector 18 nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
238 (setq i 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
239 (while (< i 48)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
240 (setq k (* (/ i 16) 6))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
241 (setq k+6 (+ k 6))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
242 (while (< k k+6)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
243 (setq temp (buffer-substring (point) (+ (point) 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
244 (aset cmp k (concat (aref cmp k) temp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
245 (setq k (1+ k))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
246 (setq temp (buffer-substring (+ (point) 2) (+ (point) 4)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
247 (aset cmp k (concat (aref cmp k) temp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
248 (setq k (1+ k))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
249 (search-forward "0x" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
250 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
251 (setq i (1+ i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
252 (delete-region (point-min)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
253 (insert "X-Face: ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
254 (setq k 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
255 (while (< k 6)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
256 (insert (bitmap-compose (aref cmp k)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
257 (setq k (1+ k))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
258 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
259 (insert ?\n)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
260 (setq i 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
261 (while (< i 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
262 (insert " ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
263 (setq k (* i 6)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
264 k+6 (+ k 6))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
265 (while (< k k+6)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
266 (insert (bitmap-compose (aref cmp k)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
267 (setq k (1+ k))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
268 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
269 (insert ?\n)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
270 (setq i (1+ i))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
271 )))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
272
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
273
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
274 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
275 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
276
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
277 (provide 'bitmap)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
278
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
279 ;;; bitmap.el ends here