From ffcd82f3b5f1fb197550b005b11cae1651a8fe34 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 7 Oct 2014 13:45:17 -0400 Subject: fix mixed up width and height --- lib/Image/PNM.pm | 4 +- t/P3.t | 26 ++++---- t/data/P3.pnm | 196 ------------------------------------------------------- t/data/P3.ppm | 148 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 163 insertions(+), 211 deletions(-) delete mode 100644 t/data/P3.pnm create mode 100644 t/data/P3.ppm 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->(), diff --git a/t/P3.t b/t/P3.t index 3c75def..1b8e663 100644 --- a/t/P3.t +++ b/t/P3.t @@ -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'), <