avoid a possible sign-extension for offsets/sizes in SGI
[imager.git] / xt / x107bmp.t
CommitLineData
8e9fefdf
TC
1#!perl -w
2# Extra BMP tests not shipped
3use strict;
4use Test::More;
5use Imager::Test qw(is_image);
6use Imager;
7
8# test images from
9my @tests =
10 (
11 [ "g01bg.bmp", "1-bit blue/green", 0 ],
12 [ "g01bw.bmp", "1-bit black and white", 0 ],
13 [ "g01p1.bmp", "1-bit single colour", 0 ],
14 [ "g01wb.bmp", "1-bit white and black", 0 ],
15 [ "g04.bmp", "4-bit", 0 ],
16 [ "g04p4.bmp", "4-bit gray", 0 ],
17 [ "g04rle.bmp", "4-bit rle", "currently broken" ],
18 [ "g08.bmp", "8-bit", 0 ],
19 [ "g08offs.bmp", "8-bit with image data offset", 0 ],
20 [ "g08os2.bmp", "8-bit OS/2", "OS/2 BMP not implemented" ],
21 [ "g08p256.bmp", "8-bit, no important", 0 ],
22 [ "g08p64.bmp", "8-bit, 64 greyscale entries", 0 ],
23 [ "g08pi256.bmp", "8-bit 256 important", 0 ],
24 [ "g08pi64.bmp", "8-bit 64 important", 0 ],
25 [ "g08res11.bmp", "8-bit, 100x100 dpi", 0 ],
26 [ "g08res21.bmp", "8-bit, 200x100 dpi", 0 ],
27 [ "g08res22.bmp", "8-bit, 200x200 dpi", 0 ],
28 [ "g08rle.bmp", "8-bit rle", 0 ],
29 [ "g08s0.bmp", "8-bit, bits size not given", 0 ],
30 [ "g08w124.bmp", "8-bit 124x61", 0 ],
31 [ "g08w125.bmp", "8-bit 125x62", 0 ],
32 [ "g08w126.bmp", "8-bit 126x63", 0 ],
33 [ "g16bf555.bmp", "16-bit bitfield 555", 0 ],
34 [ "g16bf565.bmp", "16-bit bitfield 565", 0 ],
35 [ "g16def555.bmp", "16-bit default 555", 0 ],
36 [ "g24.bmp", "24-bit", 0 ],
37 [ "g32bf.bmp", "32-bit bitfields", 0 ],
38 [ "g32def.bmp", "32-bit defaults", 0 ],
39 [ "test32bfv4.bmp", "32-bit bitfields, v4", "v4 BMP not implemented" ],
40 [ "test32v5.bmp", "32-bit, v5", "v5 BMP not implemented" ],
41 [ "test4os2v2.bmp", "4-bit OS/2", "OS/2 BMP not implemented" ],
42 [ "trans.bmp", "transparency", "alpha BMPs not implemented" ],
43 [ "width.bmp", "odd-width rle", "currently broken" ],
44 );
45
46Imager->open_log(log => "testout/x107bmp.log");
47
48plan tests => 3 * @tests;
49
50for my $test (@tests) {
51 my ($in, $note, $todo) = @$test;
52
53 my $im = Imager->new(file => "xtestimg/bmp/$in");
54 local $TODO = $todo;
55 ok($im, "load $in ($note)")
56 or diag "$in: ".Imager->errstr;
57 (my $alt = $in) =~ s/\.bmp$/.sgi/;
58
59 my $ref = Imager->new(file => "xtestimg/bmp/$alt");
60 {
61 local $TODO; # should always pass
62 ok($ref, "load reference image for $in")
63 or diag "$alt: ".Imager->errstr;
64 if ($ref->getchannels == 1) {
65 $ref = $ref->convert(preset => "rgb");
66 }
67 }
68 is_image($im, $ref, "compare $note");
69}
70
71Imager->close_log();
72