📄 codeword.cpp
字号:
// ******************************************************************** //
// //
// CODEWORD.CPP //
// Copyright (c) 1993, Michael Holmes and Bob Flanders //
// C++ Communication Utilities //
// //
// This file contains the tables to support conversion between //
// G3 fax codewords and a bitmapped array. //
// //
// The code_entry structure is used in converting from the //
// G3 format to a bitmapped format. The code_table variable //
// is arranged as a two dimensional array. The indices are on //
// color (white and black) and number of bits. Based on the //
// current color being searched for and the number of bits //
// retrieved from the input stream, the shorter arrays are //
// searched. If a match is found, the value element represents //
// the number of pels for the this codeword. //
// //
// The encode_table structure is used to encode a bitmap into //
// a G3 fax format data stream. This table is indexed by the //
// number of bits and their color. The first 64 entries are //
// direct translations. The remaining entries (make up codes) //
// are used as a prefix to the first 64 values. //
// //
// ******************************************************************** //
struct code_entry // codeword translation entries
{
unsigned
char code; // codeword (right justified)
int value; // value of codeword
} code_bl2[] = // 2 bit black codewords
{
{ 2, 3 }, // 10
{ 3, 2 }, // 11
{ 0, 0 }
},
code_bl3[] = // 3 bit black codewords
{
{ 2, 1 }, // 010
{ 3, 4 }, // 011
{ 0, 0 }
},
code_wh4[] = // 4 bit white codewords
{
{ 7, 2 }, // 0111
{ 8, 3 }, // 1000
{ 11, 4 }, // 1011
{ 12, 5 }, // 1100
{ 14, 6 }, // 1110
{ 15, 7 }, // 1111
{ 0, 0 }
},
code_bl4[] = // 4 bit black codewords
{
{ 2, 6 }, // 0010
{ 3, 5 }, // 0011
{ 0, 0 }
},
code_wh5[] = // 5 bit white codewords
{
{ 7, 10 }, // 00111
{ 8, 11 }, // 01000
{ 18, 128 }, // 10010
{ 19, 8 }, // 10011
{ 20, 9 }, // 10100
{ 27, 64 }, // 11011
{ 0, 0 }
},
code_bl5[] = // 5 bit black codewords
{
{ 3, 7 }, // 00011
{ 0, 0 }
},
code_wh6[] = // 6 bit white codewords
{
{ 3, 13 }, // 000011
{ 7, 1 }, // 000111
{ 8, 12 }, // 001000
{ 23, 192 }, // 010111
{ 24, 1664 }, // 011000
{ 42, 16 }, // 101010
{ 43, 17 }, // 101011
{ 52, 14 }, // 110100
{ 53, 15 }, // 110101
{ 0, 0 }
},
code_bl6[] = // 6 bit black codewords
{
{ 4, 9 }, // 000100
{ 5, 8 }, // 000101
{ 0, 0 }
},
code_wh7[] = // 7 bit white codewords
{
{ 3, 22 }, // 0000011
{ 4, 23 }, // 0000100
{ 8, 20 }, // 0001000
{ 12, 19 }, // 0001100
{ 19, 26 }, // 0010011
{ 23, 21 }, // 0010111
{ 24, 28 }, // 0011000
{ 36, 27 }, // 0100100
{ 39, 18 }, // 0100111
{ 40, 24 }, // 0101000
{ 43, 25 }, // 0101011
{ 55, 256 }, // 0110111
{ 0, 0 }
},
code_bl7[] = // 7 bit black codewords
{
{ 4, 10 }, // 0000100
{ 5, 11 }, // 0000101
{ 7, 12 }, // 0000111
{ 0, 0 }
},
code_wh8[] = // 8 bit white codewords
{
{ 2, 29 }, // 00000010
{ 3, 30 }, // 00000011
{ 4, 45 }, // 00000100
{ 5, 46 }, // 00000101
{ 10, 47 }, // 00001010
{ 11, 48 }, // 00001011
{ 18, 33 }, // 00010010
{ 19, 34 }, // 00010011
{ 20, 35 }, // 00010100
{ 21, 36 }, // 00010101
{ 22, 37 }, // 00010110
{ 23, 38 }, // 00010111
{ 26, 31 }, // 00011010
{ 27, 32 }, // 00011011
{ 36, 53 }, // 00100100
{ 37, 54 }, // 00100101
{ 40, 39 }, // 00101000
{ 41, 40 }, // 00101001
{ 42, 41 }, // 00101010
{ 43, 42 }, // 00101011
{ 44, 43 }, // 00101100
{ 45, 44 }, // 00101101
{ 50, 61 }, // 00110010
{ 51, 62 }, // 00110011
{ 52, 63 }, // 00110100
{ 53, 0 }, // 00110101
{ 54, 320 }, // 00110110
{ 55, 384 }, // 00110111
{ 74, 59 }, // 01001010
{ 75, 60 }, // 01001011
{ 82, 49 }, // 01010010
{ 83, 50 }, // 01010011
{ 84, 51 }, // 01010100
{ 85, 52 }, // 01010101
{ 88, 55 }, // 01011000
{ 89, 56 }, // 01011001
{ 90, 57 }, // 01011010
{ 91, 58 }, // 01011011
{ 100, 448 }, // 01100100
{ 101, 512 }, // 01100101
{ 103, 640 }, // 01100111
{ 104, 576 }, // 01101000
{ 0, 0 }
},
code_bl8[] = // 8 bit black codewords
{
{ 4, 13 }, // 00000100
{ 7, 14 }, // 00000111
{ 0, 0 }
},
code_wh9[] = // 9 bit white codewords
{
{ 152, 1472 }, // 010011000
{ 153, 1536 }, // 010011001
{ 154, 1600 }, // 010011010
{ 155, 1728 }, // 010011011
{ 204, 704 }, // 011001100
{ 205, 768 }, // 011001101
{ 210, 832 }, // 011010010
{ 211, 896 }, // 011010011
{ 212, 960 }, // 011010100
{ 213, 1024 }, // 011010101
{ 214, 1088 }, // 011010110
{ 215, 1152 }, // 011010111
{ 216, 1216 }, // 011011000
{ 217, 1280 }, // 011011001
{ 218, 1344 }, // 011011010
{ 219, 1408 }, // 011011011
{ 0, 0 }
},
code_bl9[] = // 9 bit black codewords
{
{ 24, 15 }, // 000011000
{ 0, 0 }
},
code_bl10[] = // 10 bit black codewords
{
{ 8, 18 }, // 0000001000
{ 15, 64 }, // 0000001111
{ 23, 16 }, // 0000010111
{ 24, 17 }, // 0000011000
{ 55, 0 }, // 0000110111
{ 0, 0 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -