3 use Test::More tests => 25;
5 BEGIN { use_ok('Imager::File::CUR'); }
7 -d 'testout' or mkdir 'testout', 0777;
11 ok($im->read(file => 'testimg/pal43232.cur', type=>'cur'),
13 is($im->getwidth, 32, "check width");
14 is($im->getheight, 32, "check width");
15 is($im->type, 'paletted', "check type");
16 is($im->tags(name => 'cur_bits'), 4, "check cur_bits tag");
17 is($im->tags(name => 'i_format'), 'cur', "check i_format tag");
18 is($im->tags(name => 'cur_hotspotx'), 1, "check cur_hotspotx tag");
19 is($im->tags(name => 'cur_hotspoty'), 18, "check cur_hotspoty tag");
20 my $mask = ".*" . ("\n" . "." x 32) x 32;
21 is($im->tags(name => 'cur_mask'), $mask, "check cur_mask tag");
23 # these should get pushed back into range on saving
24 $im->settag(name => 'cur_hotspotx', value => 32);
25 $im->settag(name => 'cur_hotspoty', value => -1);
26 ok($im->write(file=>'testout/hotspot.cur', type=>'cur'),
27 "save with oor hotspot")
28 or print "# ",$im->errstr, "\n";
30 my $im2 = Imager->new;
31 ok($im2->read(file=>'testout/hotspot.cur', type=>'cur'),
32 "re-read the hotspot set cursor")
33 or print "# ", $im->errstr, "\n";
34 is($im2->tags(name => 'cur_hotspotx'), 31, "check cur_hotspotx tag");
35 is($im2->tags(name => 'cur_hotspoty'), 0, "check cur_hotspoty tag");
38 $im->settag(name => 'cur_hotspotx', value => -1);
39 $im->settag(name => 'cur_hotspoty', value => 32);
40 ok($im->write(file=>'testout/hotspot2.cur', type=>'cur'),
41 "save with oor hotspot")
42 or print "# ",$im->errstr, "\n";
45 my $im2 = Imager->new;
46 ok($im2->read(file=>'testout/hotspot2.cur', type=>'cur'),
47 "re-read the hotspot set cursor")
48 or print "# ", $im->errstr, "\n";
49 is($im2->tags(name => 'cur_hotspotx'), 0, "check cur_hotspotx tag");
50 is($im2->tags(name => 'cur_hotspoty'), 31, "check cur_hotspoty tag");
55 ok($im->write(data => \$data, type => 'cur'),
56 "write single to data");
57 print "# ", length $data, " bytes written\n";
58 my $im2 = Imager->new;
59 ok($im2->read(data => $data), "read back in");
60 is(Imager::i_img_diff($im->{IMG}, $im2->{IMG}), 0, "check image");
65 ok(Imager->write_multi({ type => 'cur', data => \$data }, $im, $im),
66 "write multiple images");
67 print "# ", length $data, " bytes written\n";
68 my @im = Imager->read_multi(type => 'cur', data => $data)
69 or print "# ", Imager->errstr, "\n";
70 is(@im, 2, "read them back in");
71 is(Imager::i_img_diff($im->{IMG}, $im[0]{IMG}), 0, "check first image");
72 is(Imager::i_img_diff($im->{IMG}, $im[1]{IMG}), 0, "check second image");