]> git.imager.perl.org - imager.git/commitdiff
PNG re-work: add more image type TODO tests
authorTony Cook <tony@develop-help.com>
Wed, 2 Nov 2011 11:58:53 +0000 (22:58 +1100)
committerTony Cook <tony@develop-help.com>
Sun, 29 Apr 2012 03:40:55 +0000 (13:40 +1000)
MANIFEST
PNG/t/10png.t
PNG/testimg/bilevel.png [new file with mode: 0644]
PNG/testimg/rgb16.png [new file with mode: 0644]

index 64f5975d0d23e68820c53e4149ce6519c0941f32..4d07d3e8419c6b9e530f2b94a168545916822fc9 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -226,8 +226,14 @@ PNG/README
 PNG/t/00load.t
 PNG/t/10png.t                  Test png support
 PNG/testimg/badcrc.png
+PNG/testimg/bilevel.png
+PNG/testimg/gray.png
+PNG/testimg/graya.png
+PNG/testimg/pal.png
 PNG/testimg/palette.png
 PNG/testimg/palette_out.png
+PNG/testimg/paltrans.png
+PNG/testimg/rgb16.png
 pnm.c
 polygon.c
 ppport.h
index 3ebe9c43146aa68eb5cda6c5e267f874e79f9829..c3a248ceeacc9f5d0228218072fb7606865a5466 100644 (file)
@@ -13,7 +13,7 @@ init_log("testout/t102png.log",1);
 $Imager::formats{"png"}
   or plan skip_all => "No png support";
 
-plan tests => 63;
+plan tests => 73;
 
 diag("Library version " . Imager::File::PNG::i_png_lib_version());
 
@@ -230,6 +230,7 @@ SKIP:
      "read grayscale");
   is($im->getchannels, 1, "check channel count");
   is($im->type, "direct", "check type");
+  is($im->bits, 8, "check bits");
 }
 
 { # test grayscale + alpha read as greyscale + alpha
@@ -238,6 +239,7 @@ SKIP:
      "read grayscale + alpha");
   is($im->getchannels, 2, "check channel count");
   is($im->type, "direct", "check type");
+  is($im->bits, 8, "check bits");
 }
 
 { # test paletted + alpha read as paletted
@@ -252,10 +254,30 @@ SKIP:
 { # test paletted read as paletted
   my $im = Imager->new;
   ok($im->read(file => "testimg/pal.png", type => "png"),
-     "read paletted with alpha");
+     "read paletted");
+  is($im->getchannels, 3, "check channel count");
+  local $TODO = "Not yet implemented";
+  is($im->type, "paletted", "check type");
+}
+
+{ # test 16-bit rgb read as 16 bit
+  my $im = Imager->new;
+  ok($im->read(file => "testimg/rgb16.png", type => "png"),
+     "read 16-bit rgb");
   is($im->getchannels, 3, "check channel count");
+  is($im->type, "direct", "check type");
+  local $TODO = "Not yet implemented";
+  is($im->bits, 16, "check bits");
+}
+
+{ # test 1-bit grey read as mono
+  my $im = Imager->new;
+  ok($im->read(file => "testimg/bilevel.png", type => "png"),
+     "read bilevel png");
+  is($im->getchannels, 1, "check channel count");
   local $TODO = "Not yet implemented";
   is($im->type, "paletted", "check type");
+  ok($im->is_bilevel, "should be bilevel");
 }
 
 sub limited_write {
diff --git a/PNG/testimg/bilevel.png b/PNG/testimg/bilevel.png
new file mode 100644 (file)
index 0000000..7be3a21
Binary files /dev/null and b/PNG/testimg/bilevel.png differ
diff --git a/PNG/testimg/rgb16.png b/PNG/testimg/rgb16.png
new file mode 100644 (file)
index 0000000..232a6f0
Binary files /dev/null and b/PNG/testimg/rgb16.png differ