blob: 62bc38a705dad29c423d863f9dcb27a8985cf099 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#!@SHELL@
# compression of 6-level inks (irrespective of bits per level)
# 3-level, 5 pixels = 1024 combinations: 10 bits long
# but since not all levels used: unique are 242, or 1 byte
# 4-level, 4 pixels = 65536 combinations: 16 bits long
# but since only 2 bits per pixel used there are 256 combinations, or 1 byte
# 5-level, 3 pixels: 15 bits long
# but since only 3 bits per pixel used there are 125 unique combinations, or 1 byte
# 6-level, 3 pixels: 15 bits long
# but since only 3 bits per pixel used there are 216 unique combinations, or 1 byte
# m: max number of levels used
m=6
# z: max number allowed by bits
z=16
# a: iteration of array subscript
a=1
# n: iteration of valid combinations
n=0
# iteration of pixels
#i=0
j=0
k=0
l=0
echo "static const unsigned char ninetoeight2[] ="
echo "{"
#for (( i=1; i<=$z; i++ ))
#do
for (( j=1; j<=$z; j++ ))
do
for (( k=1; k<=$z; k++ ))
do
for (( l=1; l<=$z; l++ ))
do
# if test $i -gt $m -o $j -gt $m -o $k -gt $m -o $l -gt $m
if test $j -gt $m -o $k -gt $m -o $l -gt $m
then
array[$a]=0
else
array[$a]=$n
n=$(( $n+1 ))
fi
# print line of output
remainder=$(( $a % 16 ))
a=$(( $a+1 ))
if test $remainder -eq 0
then
printf " "
pstart=$(( 256*($j-1)+16*($k-1)+1 ))
pfinal=$(( 256*($j-1)+16*$k ))
#echo "array subscript: $a, pstart: $pstart, pfinal: $pfinal, iterators: $j $k $l"
for (( p=$pstart; p<=$pfinal; p++ ))
do
printf "%3d," ${array[$p]}
done
printf "\n"
fi
done
done
done
#done
echo "};"
echo "max number of valid combinations: $n"
|