]> git.imager.perl.org - imager.git/blob - t/t68map.t
600887ded279d58b628812ac041f54504e1cca14
[imager.git] / t / t68map.t
1 -d "testout" or mkdir "testout";
2
3 Imager::init("log"=>'testout/t68map.log');
4
5 use Imager qw(:all :handy);
6
7 print "1..5\n";
8
9 my $imbase = Imager::ImgRaw::new(200,300,3);
10
11
12 @map1 = map { int($_/2) } 0..255;
13 @map2 = map { 255-int($_/2) } 0..255;
14 @map3 = 0..255;
15 @maps = 0..24;
16 @mapl = 0..400;
17
18 $tst = 1;
19
20 i_map($imbase, [ [],     [],     \@map1 ]);
21 print "ok ".$tst++."\n";
22 i_map($imbase, [ \@map1, \@map1, \@map1 ]);
23
24 print "ok ".$tst++."\n";
25 i_map($imbase, [ \@map1, \@map2, \@map3 ]);
26
27 print "ok ".$tst++."\n";
28 i_map($imbase, [ \@maps, \@mapl, \@map3 ]);
29
30 # test the highlevel interface
31 # currently this requires visual inspection of the output files
32
33
34 my $im = Imager->new;
35 if ($im->read(file=>'testimg/scale.ppm')) {
36   print( ( $im->map(red=>\@map1, green=>\@map2, blue=>\@map3) ? "ok " : "not ok ").$tst++."\n" );
37   print( ( $im->map(maps=>[\@map1, [], \@map2]) ? "ok " : "not ok "). $tst++."\n");
38 }
39 else {
40   die "could not load testout/scale.ppm\n";
41 }