PNG re-work: simple tests for reading various images types
authorTony Cook <tony@develop-help.com>
Tue, 14 Jun 2011 13:49:51 +0000 (23:49 +1000)
committerTony Cook <tony@develop-help.com>
Sun, 29 Apr 2012 03:40:55 +0000 (13:40 +1000)
including TODOs for paletted checks

PNG/t/10png.t
PNG/testimg/gray.png [new file with mode: 0644]
PNG/testimg/graya.png [new file with mode: 0644]
PNG/testimg/pal.png [new file with mode: 0644]
PNG/testimg/paltrans.png [new file with mode: 0644]

index 7a28c41..3ebe9c4 100644 (file)
@@ -13,7 +13,7 @@ init_log("testout/t102png.log",1);
 $Imager::formats{"png"}
   or plan skip_all => "No png support";
 
-plan tests => 51;
+plan tests => 63;
 
 diag("Library version " . Imager::File::PNG::i_png_lib_version());
 
@@ -224,6 +224,40 @@ SKIP:
   }
 }
 
+{ # test grayscale read as greyscale
+  my $im = Imager->new;
+  ok($im->read(file => "testimg/gray.png", type => "png"),
+     "read grayscale");
+  is($im->getchannels, 1, "check channel count");
+  is($im->type, "direct", "check type");
+}
+
+{ # test grayscale + alpha read as greyscale + alpha
+  my $im = Imager->new;
+  ok($im->read(file => "testimg/graya.png", type => "png"),
+     "read grayscale + alpha");
+  is($im->getchannels, 2, "check channel count");
+  is($im->type, "direct", "check type");
+}
+
+{ # test paletted + alpha read as paletted
+  my $im = Imager->new;
+  ok($im->read(file => "testimg/paltrans.png", type => "png"),
+     "read paletted with alpha");
+  is($im->getchannels, 4, "check channel count");
+  local $TODO = "Not yet implemented";
+  is($im->type, "paletted", "check type");
+}
+
+{ # test paletted read as paletted
+  my $im = Imager->new;
+  ok($im->read(file => "testimg/pal.png", type => "png"),
+     "read paletted with alpha");
+  is($im->getchannels, 3, "check channel count");
+  local $TODO = "Not yet implemented";
+  is($im->type, "paletted", "check type");
+}
+
 sub limited_write {
   my ($limit) = @_;
 
diff --git a/PNG/testimg/gray.png b/PNG/testimg/gray.png
new file mode 100644 (file)
index 0000000..b81838f
Binary files /dev/null and b/PNG/testimg/gray.png differ
diff --git a/PNG/testimg/graya.png b/PNG/testimg/graya.png
new file mode 100644 (file)
index 0000000..3eaae35
Binary files /dev/null and b/PNG/testimg/graya.png differ
diff --git a/PNG/testimg/pal.png b/PNG/testimg/pal.png
new file mode 100644 (file)
index 0000000..2fc0fe7
Binary files /dev/null and b/PNG/testimg/pal.png differ
diff --git a/PNG/testimg/paltrans.png b/PNG/testimg/paltrans.png
new file mode 100644 (file)
index 0000000..6d7c3b3
Binary files /dev/null and b/PNG/testimg/paltrans.png differ