From: Tony Cook Date: Mon, 7 Jan 2002 10:55:50 +0000 (+0000) Subject: ascii pbms weren't treated correctly X-Git-Tag: Imager-0.48^2~458 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/91492c5eb42625a929ffb48030e242054877e333 ascii pbms weren't treated correctly --- diff --git a/Changes b/Changes index 31a01734..f0db98cf 100644 --- a/Changes +++ b/Changes @@ -577,6 +577,7 @@ Revision history for Perl extension Imager. - add tests for each type of iolayer in t50basicoo.t - read/write multi-image tiff files - tests in t50basicoo.t for multi-image/file + - ASCII PBM files were reading white as dark gray (255 vs 1) ================================================================= diff --git a/MANIFEST b/MANIFEST index 30106a41..2e2ceae5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -133,6 +133,7 @@ testimg/scale.ppm testimg/scalei.gif testimg/screen2.gif testimg/screen3.gif +testimg/simple.pbm testimg/test_gimp_pal A simple GIMP palette file testimg/trimgdesc.gif testimg/trmiddesc.gif diff --git a/pnm.c b/pnm.c index aff05f8b..a4e1753b 100644 --- a/pnm.c +++ b/pnm.c @@ -354,7 +354,7 @@ i_readpnm_wiol(io_glue *ig, int length) { for(y=0;ynew; +$ooim->read(file=>"testimg/simple.pbm") or print "not "; +print "ok 9\n"; + +check_gray(10, Imager::i_get_pixel($ooim->{IMG}, 0, 0), 255); +check_gray(11, Imager::i_get_pixel($ooim->{IMG}, 0, 1), 0); +check_gray(12, Imager::i_get_pixel($ooim->{IMG}, 1, 0), 0); +check_gray(13, Imager::i_get_pixel($ooim->{IMG}, 1, 1), 255); + sub openimage { my $fname = shift; local(*FH); @@ -80,3 +89,15 @@ sub slurp { close($fh); return $data; } + +sub check_gray { + my ($num, $c, $gray) = @_; + + my ($g) = $c->rgba; + if ($g == $gray) { + print "ok $num\n"; + } + else { + print "not ok $num # $g doesn't match $gray\n"; + } +} diff --git a/testimg/simple.pbm b/testimg/simple.pbm new file mode 100644 index 00000000..794da15e --- /dev/null +++ b/testimg/simple.pbm @@ -0,0 +1,5 @@ +P1 +# test image +2 2 +1 0 +0 1