3 * Copyright 2000 Y.Takagi All Rights Reserved.
13 #define MAX_ELEMENT (MAX_HORTZ * MAX_VERT)
15 #include "original_dither_pattern.h"
17 void create_index_table(const unsigned char *p1
, unsigned char *p2
)
19 for (int i
= 0 ; i
< MAX_ELEMENT
; i
++) {
25 inline int index2horz(int index
)
27 return index
% MAX_HORTZ
;
30 inline int index2vert(int index
)
32 return index
/ MAX_HORTZ
;
35 void create_pattern16x16(const unsigned char *pattern4x4
, unsigned char *pattern16x16
)
37 unsigned char value2index
[MAX_ELEMENT
];
38 create_index_table(pattern4x4
, value2index
);
40 for (int i
= 0 ; i
< MAX_ELEMENT
; i
++) {
41 int index
= value2index
[i
];
42 int h
= index2horz(index
);
43 int v
= index2vert(index
);
44 for (int j
= 0 ; j
< MAX_ELEMENT
; j
++) {
45 int index2
= value2index
[j
];
46 int h2
= index2horz(index2
) * 4 + h
;
47 int v2
= index2vert(index2
) * 4 + v
;
48 pattern16x16
[h2
+ v2
* MAX_ELEMENT
] = j
+ i
* MAX_ELEMENT
;
53 void print_pattern(ostream
&os
, const char *name
, const unsigned char *pattern
)
55 os
<< "const unsigned char " << name
<< "[] = {" << '\n' << '\t';
56 for (int i
= 0 ; i
< 256 ; i
++) {
57 os
<< setw(3) << (int)pattern
[i
];
58 if (i
== MAX_ELEMENT
* MAX_ELEMENT
- 1) {
62 if (i
% MAX_ELEMENT
== MAX_ELEMENT
- 1) {
72 unsigned char pattern16x16_type1
[MAX_ELEMENT
* MAX_ELEMENT
];
73 create_pattern16x16(pattern4x4_type1
, pattern16x16_type1
);
74 print_pattern(cout
, "pattern16x16_type1", pattern16x16_type1
);
78 unsigned char pattern16x16_type2
[MAX_ELEMENT
* MAX_ELEMENT
];
79 create_pattern16x16(pattern4x4_type2
, pattern16x16_type2
);
80 print_pattern(cout
, "pattern16x16_type2", pattern16x16_type2
);
84 unsigned char pattern16x16_type3
[MAX_ELEMENT
* MAX_ELEMENT
];
85 create_pattern16x16(pattern4x4_type3
, pattern16x16_type3
);
86 print_pattern(cout
, "pattern16x16_type3", pattern16x16_type3
);