Debian Codegraph @

test/compress-6level.sh.in

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