| 1 | #!perl -w | ||||||||||
| 2 | 1 | ▶ | use Imager; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use Test::More tests => 14; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Imager::Test qw(is_image); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | { | ||||||||||
| 7 | # SGI files are limited to 0xFFFF x 0xFFFF pixels | ||||||||||
| 8 | 1 | { | |||||||||
| 9 | 1 | my $im = Imager->new(xsize => 0x10000, ysize => 1); | |||||||||
| 10 | 1 | my $data = ''; | |||||||||
| 11 | 1 | ok(!$im->write(data => \$data, type => "sgi"), | |||||||||
| 12 | "fail to write too wide an image"); | ||||||||||
| 13 | 1 | is($im->errstr, "image too large for SGI", | |||||||||
| 14 | "check error message"); | ||||||||||
| 15 | } | ||||||||||
| 16 | SKIP: | ||||||||||
| 17 | { | ||||||||||
| 18 | 1 | my $im = Imager->new(xsize => 0xFFFF, ysize => 1); | |||||||||
| 19 | 1 | $im->box(fill => { hatch => "check4x4" }); | |||||||||
| 20 | 1 | my $data = ''; | |||||||||
| 21 | 1 | ok($im->write(data => \$data, type => "sgi"), | |||||||||
| 22 | "write image at width limit"); | ||||||||||
| 23 | 1 | my $im2 = Imager->new(data => $data, ftype => "sgi"); | |||||||||
| 24 | 1 | ▶ | ok($im2, "read it ok") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | or skip("cannot load the wide image", 1); | ||||||||||
| 26 | 1 | is_image($im, $im2, "check we read what we wrote"); | |||||||||
| 27 | 1 | is($im->getwidth, 0xffff, "check width"); | |||||||||
| 28 | 1 | is($im->getheight, 1, "check height"); | |||||||||
| 29 | } | ||||||||||
| 30 | { | ||||||||||
| 31 | 1 | my $im = Imager->new(xsize => 1, ysize => 0x10000); | |||||||||
| 32 | 1 | my $data = ''; | |||||||||
| 33 | 1 | ok(!$im->write(data => \$data, type => "sgi"), | |||||||||
| 34 | "fail to write too tall an image"); | ||||||||||
| 35 | 1 | is($im->errstr, "image too large for SGI", | |||||||||
| 36 | "check error message"); | ||||||||||
| 37 | } | ||||||||||
| 38 | SKIP: | ||||||||||
| 39 | { | ||||||||||
| 40 | 1 | my $im = Imager->new(xsize => 1, ysize => 0xFFFF); | |||||||||
| 41 | 1 | $im->box(fill => { hatch => "check2x2" }); | |||||||||
| 42 | 1 | my $data = ''; | |||||||||
| 43 | 1 | ok($im->write(data => \$data, type => "sgi"), | |||||||||
| 44 | "write image at width limit"); | ||||||||||
| 45 | 1 | my $im2 = Imager->new(data => $data, ftype => "sgi"); | |||||||||
| 46 | 1 | ▶ | ok($im2, "read it ok") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | or skip("cannot load the wide image", 1); | ||||||||||
| 48 | 1 | is_image($im, $im2, "check we read what we wrote"); | |||||||||
| 49 | 1 | is($im->getwidth, 1, "check width"); | |||||||||
| 50 | 1 | is($im->getheight, 0xffff, "check height"); | |||||||||
| 51 | } | ||||||||||
| 52 | } | ||||||||||