diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-10-07 13:45:17 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-10-07 13:46:04 -0400 |
commit | ffcd82f3b5f1fb197550b005b11cae1651a8fe34 (patch) | |
tree | d13089d8bb0e6b434e7de35d6564d9d1efb72ad5 | |
parent | 34123b9d0460b50118a76290aafa0fc31eb365b1 (diff) | |
download | image-pnm-ffcd82f3b5f1fb197550b005b11cae1651a8fe34.tar.gz image-pnm-ffcd82f3b5f1fb197550b005b11cae1651a8fe34.zip |
fix mixed up width and height
-rw-r--r-- | lib/Image/PNM.pm | 4 | ||||
-rw-r--r-- | t/P3.t | 26 | ||||
-rw-r--r-- | t/data/P3.ppm (renamed from t/data/P3.pnm) | 50 |
3 files changed, 16 insertions, 64 deletions
diff --git a/lib/Image/PNM.pm b/lib/Image/PNM.pm index bc748e7..793750d 100644 --- a/lib/Image/PNM.pm +++ b/lib/Image/PNM.pm @@ -161,9 +161,9 @@ sub _parse_pnm_P3 { }; $self->{pixels} = []; - for my $i (1..$self->{w}) { + for my $i (1..$self->{h}) { my $row = []; - for my $j (1..$self->{h}) { + for my $j (1..$self->{w}) { push @$row, [ $next_word->(), $next_word->(), @@ -5,26 +5,26 @@ use Test::More; use Image::PNM; -my $image = Image::PNM->new('t/data/P3.pnm'); +my $image = Image::PNM->new('t/data/P3.ppm'); -is($image->width, 8); +is($image->width, 6); is($image->height, 8); is($image->max_pixel_value, 255); -is_deeply($image->raw_pixel(1, 3), [0, 84, 255]); -is_deeply($image->pixel(4, 2), [1, 0, 0]); +is_deeply($image->raw_pixel(1, 2), [0, 84, 255]); +is_deeply($image->pixel(4, 1), [1, 0, 0]); is($image->as_string('P3'), <<IMAGE); P3 -8 8 +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 -255 255 255 255 255 255 255 255 255 0 84 255 0 84 255 255 255 255 255 255 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 255 255 255 -255 255 255 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 255 255 255 -255 255 255 0 0 0 255 0 0 255 0 0 255 0 0 255 0 0 0 0 0 255 255 255 -255 255 255 0 0 0 255 255 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 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 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 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 done_testing; diff --git a/t/data/P3.pnm b/t/data/P3.ppm index df64d54..0f520a6 100644 --- a/t/data/P3.pnm +++ b/t/data/P3.ppm @@ -1,15 +1,6 @@ P3 # CREATOR: GIMP PNM Filter Version 1.1 -8 8 -255 -255 -255 -255 -255 -255 -255 -255 -255 +6 8 255 255 255 @@ -50,12 +41,6 @@ P3 255 255 255 -255 -255 -255 -255 -255 -255 0 0 0 @@ -71,12 +56,6 @@ P3 255 255 255 -255 -255 -255 -255 -255 -255 0 0 0 @@ -95,12 +74,6 @@ P3 0 0 0 -255 -255 -255 -255 -255 -255 0 0 0 @@ -119,12 +92,6 @@ P3 0 0 0 -255 -255 -255 -255 -255 -255 0 0 0 @@ -143,12 +110,6 @@ P3 0 0 0 -255 -255 -255 -255 -255 -255 0 0 0 @@ -185,12 +146,3 @@ P3 255 255 255 -255 -255 -255 -255 -255 -255 -255 -255 -255 |