summaryrefslogtreecommitdiffstats
path: root/t/P3.t
blob: 925b2d7a7c5df8d1ac1d1640e8bdd49b9f43aaca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

use Image::PNM;

my $image = Image::PNM->new('t/data/P3.ppm');

is($image->width, 6);
is($image->height, 8);
is($image->max_pixel_value, 255);
is_deeply($image->raw_pixel(1, 2), [0, 84, 255]);
is_deeply($image->pixel(4, 1), [1, 0, 0]);

is($image->as_string('P1'), <<IMAGE);
P1
6 8
0 0 0 0 0 0
0 0 1 1 0 0
0 1 0 0 1 0
1 0 0 0 0 1
1 1 1 1 1 1
1 0 0 0 0 1
1 0 0 0 0 1
0 0 0 0 0 0
IMAGE

is($image->as_string('P2'), <<IMAGE);
P2
6 8
255
255 255 255 255 255 255
255 255 78 78 255 255
255 0 255 255 0 255
0 255 255 255 255 0
0 54 54 54 54 0
0 255 255 255 255 0
0 255 255 255 255 0
255 255 255 255 255 255
IMAGE

is($image->as_string('P3'), <<IMAGE);
P3
6 8
255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 0 84 255 0 84 255 255 255 255 255 255 255
255 255 255 0 0 0 255 255 255 255 255 255 0 0 0 255 255 255
0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
0 0 0 255 0 0 255 0 0 255 0 0 255 0 0 0 0 0
0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
IMAGE

is($image->as_string('P4') . "\n", <<IMAGE);
P4
6 8
\x00\x30\x48\x84\xfc\x84\x84\x00
IMAGE

done_testing;