Emacs 能不能直接渲染 Bitmap 为图像?

GNU Unifont 得到 2 的 Bitmap 信息:

 #b00000000
 #b00000000
 #b00000000
 #b00000000
 #b00111100
 #b01000010
 #b01000010
 #b00000010
 #b00001100
 #b00010000
 #b00100000
 #b01000000
 #b01000000
 #b01111110
 #b00000000
 #b00000000

不知道 Emacs 能不能直接把它渲染为真正的图像,Emacs 有一个 define-fringe-bitmap,所以可行?如果可行,怎么操作?

可以把每行前面的#b删掉转成pbm格式再用emacs打开

1 个赞

可以,但不太像「图像」,感觉 1 渲染应该黑点效果好些?而且还没试过能不能缩小。

0用空格 1用o

开头还要加两行文件头表示类型和行列

然后C-c C-c就可以直接看了

3 个赞

如果在fringe上显示是可行的,例子:

(define-fringe-bitmap 'test-bitmap
  (vector #b00000000
          #b00000000
          #b00000000
          #b00000000
          #b00111100
          #b01000010
          #b01000010
          #b00000010
          #b00001100
          #b00010000
          #b00100000
          #b01000000
          #b01000000
          #b01111110
          #b00000000
          #b00000000))

(let ((ov (make-overlay 1 1 (current-buffer))))
  (overlay-put ov 'before-string
               (propertize " " 'display '(left-fringe test-bitmap error))))

还有一种办法是用xpm,比如:

(create-image "/* XPM */
 static char * percent[] = {
 \"8 16 2 1\",
 \"0 c #ffffff\",
 \"1 c #000000\",
 \"00000000\",
 \"00000000\",
 \"00000000\",
 \"00000000\",
 \"00111100\",
 \"01000010\",
 \"01000010\",
 \"00000010\",
 \"00001100\",
 \"00010000\",
 \"00100000\",
 \"01000000\",
 \"01000000\",
 \"01111110\",
 \"00000000\",
 \"00000000\"};"
              'xpm t :ascent 'center)

你把这段直接存到一个xpm文件,直接打开就能看到效果。

/* XPM */
 static char * percent[] = {
"8 16 2 1",
"0 c #ffffff",
"1 c #000000",
"00000000",
"00000000",
"00000000",
"00000000",
"00111100",
"01000010",
"01000010",
"00000010",
"00001100",
"00010000",
"00100000",
"01000000",
"01000000",
"01111110",
"00000000",
"00000000"};
3 个赞