日期:2014-05-16  浏览次数:20541 次

发个小东西,仅供玩玩
想自己做个把图片转换为字符画的小软件,原理就是根据图片的每个像素的灰度,转成不同的字符。
所以研究起点阵字库了。
HTML code

<html>
    <head>
        <title></title>
<script language="javascript" type="text/javascript">
    //ASCII点阵字库.
    var fontData=[
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xE0,
0x01,0xE0,0x01,0xE0,0x01,0xE0,0x01,0xE0,0x01,0xE0,0x01,0xE0,0x01,0xE0,0x00,0xC0,
0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x9E,0x0F,0x3C,0x0E,0x38,0x1C,0x70,0x18,0x60,
0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,
0x03,0x0C,0x03,0x0C,0x07,0x1C,0x06,0x18,0x06,0x18,0x7F,0xFE,0x7F,0xFE,0x06,0x18,
0x06,0x18,0x0E,0x38,0x0C,0x30,0x0C,0x30,0x7F,0xFE,0x7F,0xFE,0x0C,0x30,0x0C,0x30,
0x1C,0x70,0x18,0x60,0x18,0x60,0x18,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x07,0xE0,
0x0F,0xF0,0x1D,0xF0,0x39,0xB8,0x39,0xB8,0x39,0xB8,0x39,0x80,0x3D,0x80,0x1F,0x80,
0x0F,0xC0,0x03,0xE0,0x01,0xF0,0x01,0xF8,0x01,0xB8,0x71,0xB8,0x71,0xB8,0x71,0xB8,
0x39,0xB8,0x3D,0xB0,0x1F,0xF0,0x07,0xE0,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x08,
0x3C,0x10,0x66,0x10,0x66,0x10,0x66,0x20,0x66,0x20,0x66,0x40,0x66,0x40,0x66,0x80,
0x3C,0x80,0x19,0x98,0x01,0x3C,0x01,0x66,0x02,0x66,0x02,0x66,0x04,0x66,0x04,0x66,
0x08,0x66,0x08,0x66,0x08,0x3C,0x10,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,
0x0F,0xC0,0x1C,0x60,0x18,0x60,0x18,0x60,0x18,0x60,0x18,0xE0,0x0D,0xC0,0x0F,0x80,
0x0F,0x00,0x1F,0x00,0x3F,0x00,0x3B,0x8E,0x71,0xCE,0x70,0xEE,0x70,0xFC,0x70,0x7C,
0x78,0x3E,0x3C,0x7F,0x1F,0xF6,0x07,0xC2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,
0x1C,0x00,0x1C,0x00,0x0C,0x00,0x08,0x00,0x18,0x00,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x0E,0x00,0x1C,0x00,0x38,
0x00,0x30,0x00,0x60,0x00,0x60,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0xC0,0x00,0xC0,
0x00,0xC0,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x38,0x00,0x1C,0x00,0x0E,0x00,0x04,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x70,0x00,0x38,0x00,0x1C,0x00,
0x0C,0x00,0x06,0x00,0x06,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x03,0x00,0x03,0x00,
0x03,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x1C,0x00,0x38,0x00,0x70,0x00,0x20,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x21,0xC2,0x79,0xCF,0x3D,0xDE,
0x1F,0xFC,0x07,0xF0,0x07,0xF0,0x1F,0xFC,0x7D,0xDF,0x79,0xCF,0x21,0xC2,0x01,0xC0,
0x01,0xC0,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x