📄 text2bin.c
字号:
/* text2bin.c - source code for generating binary image
* files from text containing ASCII and
* PC compatible extended characters
*
* Fax Compression Sample Code
*
* Copyright (C) 2000 Jack Klein
* JK Technology
* Macmillan Computer Publishing
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General
* Public License along with this program; if not, write
* to the Free Software Foundation, Inc., 675 Mass Ave,
* Cambridge, MA 02139, USA.
*
* Jack Klein may be contacted by email at:
* The_C_Guru@yahoo.com
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fax.h"
/* definitions, based on fax.h */
#define OCTETS_PER_CHAR 2
#define CHARS_PER_ROW (OCTETS_PER_ROW / OCTETS_PER_CHAR)
#define SCAN_ROWS_PER_CHAR 16
#define LINES_PER_PAGE (MAXIMUM_ROWS / SCAN_ROWS_PER_CHAR)
/* The character look-up array contains an array of 16
* unsigned short integers for each character
*
* Each unsigned short int contains the bit pattern for
* one scan row of the character, using the least
* significant 16 bits of the unsigned short, even if
* unsigned short holds more than 16 bits
*
* The bit patterns are defined as they would be scanned
* by a typical scanner, with 0 bits for black where the
* character appears, and 1 bits for the background paper
*
* Each character occupies a 16 pixel width (2 mm per
* character, approximately 12.5 characters per inch
*
* For standard fax resolution each horizontal row
* generated should be output once, for high resolution
* each row should be output twice
*/
static const unsigned short CharacterSet [256] [16] =
{
/* character 00 = */
{
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
},
/* character 01 = */
{
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xC003, /* 1100000000000011 **............** */
0x3FFC, /* 0011111111111100 ..************.. */
0x33CC, /* 0011001111001100 ..**..****..**.. */
0x3FFC, /* 0011111111111100 ..************.. */
0x3FFC, /* 0011111111111100 ..************.. */
0x300C, /* 0011000000001100 ..**........**.. */
0x3C3C, /* 0011110000111100 ..****....****.. */
0x3FFC, /* 0011111111111100 ..************.. */
0x3FFC, /* 0011111111111100 ..************.. */
0xC003, /* 1100000000000011 **............** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
},
/* character 02 = */
{
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xC00F, /* 1100000000001111 **..........**** */
0x0003, /* 0000000000000011 ..............** */
0x0003, /* 0000000000000011 ..............** */
0x0CC3, /* 0000110011000011 ....**..**....** */
0x0003, /* 0000000000000011 ..............** */
0x0003, /* 0000000000000011 ..............** */
0x3033, /* 0011000000110011 ..**......**..** */
0x0FC3, /* 0000111111000011 ....******....** */
0x0003, /* 0000000000000011 ..............** */
0xC00F, /* 1100000000001111 **..........**** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
},
/* character 03 = */
{
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xC30F, /* 1100001100001111 **....**....**** */
0x0303, /* 0000001100000011 ......**......** */
0x0003, /* 0000000000000011 ..............** */
0x0003, /* 0000000000000011 ..............** */
0x0003, /* 0000000000000011 ..............** */
0x0003, /* 0000000000000011 ..............** */
0xC00F, /* 1100000000001111 **..........**** */
0xF03F, /* 1111000000111111 ****......****** */
0xFCFF, /* 1111110011111111 ******..******** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
},
/* character 04 = */
{
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFCFF, /* 1111110011111111 ******..******** */
0xF03F, /* 1111000000111111 ****......****** */
0xC00F, /* 1100000000001111 **..........**** */
0x0003, /* 0000000000000011 ..............** */
0xC00F, /* 1100000000001111 **..........**** */
0xF03F, /* 1111000000111111 ****......****** */
0xFCFF, /* 1111110011111111 ******..******** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
},
/* character 05 = */
{
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFCFF, /* 1111110011111111 ******..******** */
0xF03F, /* 1111000000111111 ****......****** */
0xF03F, /* 1111000000111111 ****......****** */
0xFCFF, /* 1111110011111111 ******..******** */
0xC30F, /* 1100001100001111 **....**....**** */
0x0303, /* 0000001100000011 ......**......** */
0xC30F, /* 1100001100001111 **....**....**** */
0xFCFF, /* 1111110011111111 ******..******** */
0xF03F, /* 1111000000111111 ****......****** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
},
/* character 06 = */
{
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFCFF, /* 1111110011111111 ******..******** */
0xF03F, /* 1111000000111111 ****......****** */
0xC00F, /* 1100000000001111 **..........**** */
0xC00F, /* 1100000000001111 **..........**** */
0x0003, /* 0000000000000011 ..............** */
0x0003, /* 0000000000000011 ..............** */
0x0003, /* 0000000000000011 ..............** */
0xC30F, /* 1100001100001111 **....**....**** */
0xFCFF, /* 1111110011111111 ******..******** */
0xF03F, /* 1111000000111111 ****......****** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
},
/* character 07 = */
{
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFC3F, /* 1111110000111111 ******....****** */
0xF00F, /* 1111000000001111 ****........**** */
0xF00F, /* 1111000000001111 ****........**** */
0xF00F, /* 1111000000001111 ****........**** */
0xFC3F, /* 1111110000111111 ******....****** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
},
/* character 08 = */
{
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x03C0, /* 0000001111000000 ......****...... */
0x0FF0, /* 0000111111110000 ....********.... */
0x0FF0, /* 0000111111110000 ....********.... */
0x0FF0, /* 0000111111110000 ....********.... */
0x03C0, /* 0000001111000000 ......****...... */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
},
/* character 09 = */
{
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFC3F, /* 1111110000111111 ******....****** */
0xF00F, /* 1111000000001111 ****........**** */
0xC3C3, /* 1100001111000011 **....****....** */
0xC3C3, /* 1100001111000011 **....****....** */
0xC3C3, /* 1100001111000011 **....****....** */
0xF00F, /* 1111000000001111 ****........**** */
0xFC3F, /* 1111110000111111 ******....****** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
0xFFFF, /* 1111111111111111 **************** */
},
/* character 0A = */
{
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x03C0, /* 0000001111000000 ......****...... */
0x0FF0, /* 0000111111110000 ....********.... */
0x3C3C, /* 0011110000111100 ..****....****.. */
0x3C3C, /* 0011110000111100 ..****....****.. */
0x3C3C, /* 0011110000111100 ..****....****.. */
0x0FF0, /* 0000111111110000 ....********.... */
0x03C0, /* 0000001111000000 ......****...... */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
0x0000, /* 0000000000000000 ................ */
},
/* character 0B = */
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -