Skip to content

Commit 9840ad0

Browse files
author
giraffedata
committed
quantization down to 1 color is now allowed
git-svn-id: https://svn.code.sf.net/p/netpbm/code/trunk@4773 9d0c8265-081b-0410-96cb-a4ca84ce46f8
1 parent 3ef55d2 commit 9840ad0

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

test/pnmquantall.ok

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
Test 1.
12
2373957371 33838
23
3892560659 33838
34
1383839923 33838
4-
1
5+
color count 20: success
6+
Test 2.
7+
452076937 33838
8+
452076937 33838
9+
452076937 33838
10+
color count 1: success
11+
Test Invalid
512
Expected failure 1
613
Expected failure 1.rm
714
Expected failure 2

test/pnmquantall.test

+34-10
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,45 @@ rose_red=${tmpdir}/rose.red
1212
rose_grn=${tmpdir}/rose.grn
1313
rose_blu=${tmpdir}/rose.blu
1414

15-
pnmquantall 20 ${rose_red} ${rose_grn} ${rose_blu}
15+
cp ${rose_red} ${rose_red}.1
16+
cp ${rose_grn} ${rose_grn}.1
17+
cp ${rose_blu} ${rose_blu}.1
1618

17-
for i in ${rose_red} ${rose_grn} ${rose_blu}
19+
echo "Test 1."
20+
21+
pnmquantall 20 ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1
22+
23+
for i in ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1
1824
do
1925
cat $i | cksum
2026
done
2127

22-
# Should print 1
28+
pamcat ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1 -tb | \
29+
pgmhist -m |\
30+
awk '$2>0 {s++};
31+
END { printf("color count %u: %s\n", s,
32+
(s==20) ? "success" : "failure") }'
2333

24-
pamcat ${rose_red} ${rose_grn} ${rose_blu} -tb | \
25-
pgmhist -m | awk '$2>0 {s++}; END { print (s<=20) }'
34+
rm ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1
2635

36+
echo "Test 2."
2737

28-
tmpdir=${tmpdir:-/tmp}
29-
rose_out=${tmpdir}/rose_out
38+
pnmquantall -ext .2 1 ${rose_red} ${rose_grn} ${rose_blu}
39+
40+
for i in ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2
41+
do
42+
cat $i | cksum
43+
done
44+
45+
pamcat ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2 -tb | \
46+
pgmhist -m |\
47+
awk '$2>0 {s++};
48+
END { printf("color count %u: %s\n", s,
49+
(s==1) ? "success" : "failure") }'
50+
51+
rm ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2
52+
53+
echo "Test Invalid"
3054

3155
echo 1>&2
3256
echo "Invalid command-line argument combinations." 1>&2
@@ -37,11 +61,11 @@ pnmquantall -ext xx 0 ${rose_red} ${rose_grn} ${rose_blu} || \
3761
echo "Expected failure 1"
3862
rm ${rose_red}xx ${rose_grn}xx ${rose_blu}xx || \
3963
echo "Expected failure 1.rm"
40-
pnmquantall -ext xx 1 ${rose_red} ${rose_grn} ${rose_blu} || \
64+
pnmquantall -ext yy ${rose_red} ${rose_grn} ${rose_blu} || \
4165
echo "Expected failure 2"
42-
rm ${rose_red}xx ${rose_grn}xx ${rose_blu}xx || \
66+
rm ${rose_red}yy ${rose_grn}yy ${rose_blu}yy || \
4367
echo "Expected failure 2.rm"
44-
pnmquantall -ext xx 2 || \
68+
pnmquantall -ext zz 2 || \
4569
echo "Expected failure 3"
4670

4771
rm ${rose_red} ${rose_grn} ${rose_blu} ${rose_ppm}

0 commit comments

Comments
 (0)