Commit | Line | Data |
---|---|---|
d08b8f85 TC |
1 | #!perl -w |
2 | use strict; | |
3 | use Imager qw(:handy); | |
4 | ||
f1ac5027 | 5 | Imager::init_log("testout/t61filters.log", 1); |
d08b8f85 TC |
6 | # meant for testing the filters themselves |
7 | my $imbase = Imager->new; | |
8 | $imbase->open(file=>'testout/t104.ppm') or die; | |
9 | my $im_other = Imager->new(xsize=>150, ysize=>150); | |
10 | $im_other->box(xmin=>30, ymin=>60, xmax=>120, ymax=>90, filled=>1); | |
11 | ||
6607600c | 12 | print "1..35\n"; |
d08b8f85 TC |
13 | |
14 | test($imbase, 1, {type=>'autolevels'}, 'testout/t61_autolev.ppm'); | |
15 | ||
16 | test($imbase, 3, {type=>'contrast', intensity=>0.5}, | |
17 | 'testout/t61_contrast.ppm'); | |
18 | ||
19 | # this one's kind of cool | |
20 | test($imbase, 5, {type=>'conv', coef=>[ -0.5, 1, -0.5, ], }, | |
21 | 'testout/t61_conv.ppm'); | |
22 | ||
23 | test($imbase, 7, {type=>'gaussian', stddev=>5 }, | |
24 | 'testout/t61_gaussian.ppm'); | |
25 | ||
26 | test($imbase, 9, { type=>'gradgen', dist=>1, | |
27 | xo=>[ 10, 10, 120 ], | |
28 | yo=>[ 10, 140, 60 ], | |
29 | colors=> [ NC('#FF0000'), NC('#FFFF00'), NC('#00FFFF') ]}, | |
30 | 'testout/t61_gradgen.ppm'); | |
31 | ||
32 | test($imbase, 11, {type=>'mosaic', size=>8}, 'testout/t61_mosaic.ppm'); | |
33 | ||
34 | test($imbase, 13, {type=>'hardinvert'}, 'testout/t61_hardinvert.ppm'); | |
35 | ||
36 | test($imbase, 15, {type=>'noise'}, 'testout/t61_noise.ppm'); | |
37 | ||
38 | test($imbase, 17, {type=>'radnoise'}, 'testout/t61_radnoise.ppm'); | |
39 | ||
40 | test($imbase, 19, {type=>'turbnoise'}, 'testout/t61_turbnoise.ppm'); | |
41 | ||
42 | test($imbase, 21, {type=>'bumpmap', bump=>$im_other, lightx=>30, lighty=>30}, | |
43 | 'testout/t61_bumpmap.ppm'); | |
44 | ||
45 | test($imbase, 23, {type=>'postlevels', levels=>3}, 'testout/t61_postlevels.ppm'); | |
46 | ||
47 | test($imbase, 25, {type=>'watermark', wmark=>$im_other }, | |
48 | 'testout/t61_watermark.ppm'); | |
49 | ||
6607600c TC |
50 | test($imbase, 27, {type=>'fountain', xa=>75, ya=>75, xb=>85, yb=>30, |
51 | repeat=>'triangle', #ftype=>'radial', | |
52 | super_sample=>'circle', ssample_param => 16, | |
53 | }, | |
54 | 'testout/t61_fountain.ppm'); | |
55 | use Imager::Fountain; | |
56 | ||
57 | my $f1 = Imager::Fountain->new; | |
58 | $f1->add(end=>0.2, c0=>NC(255, 0,0), c1=>NC(255, 255,0)); | |
59 | $f1->add(start=>0.2, c0=>NC(255,255,0), c1=>NC(0,0,255,0)); | |
60 | test($imbase, 29, { type=>'fountain', xa=>20, ya=>130, xb=>130, yb=>20, | |
61 | #repeat=>'triangle', | |
62 | segments=>$f1 | |
63 | }, | |
64 | 'testout/t61_fountain2.ppm'); | |
65 | my $f2 = Imager::Fountain->new | |
66 | ->add(end=>0.5, c0=>NC(255,0,0), c1=>NC(255,0,0), color=>'hueup') | |
67 | ->add(start=>0.5, c0=>NC(255,0,0), c1=>NC(255,0,0), color=>'huedown'); | |
68 | #use Data::Dumper; | |
69 | #print Dumper($f2); | |
70 | test($imbase, 31, { type=>'fountain', xa=>20, ya=>130, xb=>130, yb=>20, | |
71 | segments=>$f2 }, | |
72 | 'testout/t61_fount_hsv.ppm'); | |
73 | my $f3 = Imager::Fountain->read(gimp=>'testimg/gimpgrad') | |
74 | or print "not "; | |
75 | print "ok 33\n"; | |
efdc2568 | 76 | test($imbase, 34, { type=>'fountain', xa=>75, ya=>75, xb=>90, yb=>15, |
6607600c | 77 | segments=>$f3, super_sample=>'grid', |
efdc2568 | 78 | ftype=>'radial_square', combine=>'color' }, |
6607600c TC |
79 | 'testout/t61_fount_gimp.ppm'); |
80 | ||
d08b8f85 TC |
81 | sub test { |
82 | my ($in, $num, $params, $out) = @_; | |
83 | ||
84 | my $copy = $in->copy; | |
85 | if ($copy->filter(%$params)) { | |
86 | print "ok $num\n"; | |
87 | if ($copy->write(file=>$out)) { | |
88 | print "ok ",$num+1,"\n"; | |
89 | } | |
90 | else { | |
91 | print "not ok ",$num+1," # ",$copy->errstr,"\n"; | |
92 | } | |
93 | } | |
94 | else { | |
95 | print "not ok $num # ",$copy->errstr,"\n"; | |
96 | print "ok ",$num+1," # skipped\n"; | |
97 | } | |
98 | } |