1
# Created on: Fri 14 Dec 2007 07:22:09 PM
2
# Last saved: Fri 15 May 2009 09:40:50 AM
4
# This tests the 16-bit image capabilities of the rpic() and wpic()
5
# commands. The new code works with PNM output files and PNG format
8
# Our new default testing framework
15
eval "use PDL::IO::Pic;";
19
if($^O =~ /MSWin32/i) {
20
$test_pnmtopng = `pnmtopng --help 2>&1`;
21
$test_pnmtopng = $test_pnmtopng =~ /^pnmtopng:/ ? 1 : 0;
22
} elsif ( !defined( scalar( qx(pnmtopng --help 2>&1) ) ) ) {
26
plan skip_all => 'PDL::IO::Pic not available'
28
use_ok('PDL::IO::Pic');
31
$PDL::IO::Pic::debug=20;
33
# test save/restore of 8-bit image
34
my $a = sequence(16, 16);
35
$a->wpic('tbyte_a.pnm');
36
my $a_pnm = rpic('tbyte_a.pnm');
37
ok(sum(abs($a-$a_pnm)) == 0, 'pnm byte image save+restore');
41
skip ": pnmtopng not found, is NetPBM installed?", 1 unless $test_pnmtopng;
42
$a->wpic('tbyte_a.png');
44
unless($^O =~ /MSWin32/i) {$a_png = rpic('tbyte_a.png')}
45
else {$a_png = rpic('tbyte_a.png', {FORMAT => 'PNG'})}
46
ok(sum(abs($a-$a_png)) == 0, 'png byte image save+restore'); #test 3
50
# test save/restore of 16-bit image
51
my $a16 = sequence(256, 255)->ushort * 231;
52
$a16->wpic('tushort_a16.pnm');
53
my $a16_pnm = rpic('tushort_a16.pnm');
54
ok(sum(abs($a16-$a16_pnm)) == 0, 'pnm ushort image save+restore'); # test 4
55
unlink 'tushort_a16.pnm';
58
skip ": pnmtopng not found, is NetPBM installed?", 1 unless $test_pnmtopng;
59
$a16->wpic('tushort_a16.png');
61
unless($^O =~ /MSWin32/i) {$a16_png = rpic('tushort_a16.png')}
62
else {$a16_png = rpic('tushort_a16.png', {FORMAT => 'PNG'})}
63
ok(sum(abs($a16-$a16_png)) == 0, 'png ushort image save+restore'); # test 5 (fails on Win32 if not skipped)
64
unlink 'tushort_a16.png';