#!perl -w use strict; use Test::More tests => 4; use Imager; use Imager::File::XPM; { my $im = Imager->new(xsize => 10, ysize => 10); $im->box(filled => 1, color => '#0000FF', xmin => 5); #$im->read(file => '../Imager/testimg/209_yonge.jpg'); my $data; ok($im->write(type => 'xpm', data => \$data), "simple write"); is($data, <<'END_DATA', "matches"); /* XPM */ static char *noname[] = { /* width height ncolors chars_per_pixel */ "10 10 2 1", " c #000000", ". c #0000ff", /* pixels */ " .....", " .....", " .....", " .....", " .....", " .....", " .....", " .....", " .....", " ....." }; END_DATA } { my $im = Imager->new(xsize => 10, ysize => 10, channels => 4); $im->box(filled => 1, color => '#FF0000', xmin => 5, ymin => 5); $im->box(filled => 1, color => '#00FF00', xmin => 5, ymax => 4); $im->box(filled => 1, color => '#0000FF', xmax => 4, ymin => 5); my $data; ok($im->write(type => 'xpm', data => \$data), "write transparent"); is($data, <<'END_DATA', "matches"); /* XPM */ static char *noname[] = { /* width height ncolors chars_per_pixel */ "10 10 4 1", " c none", ". c #0000ff", "x c #00ff00", "X c #ff0000", /* pixels */ " xxxxx", " xxxxx", " xxxxx", " xxxxx", " xxxxx", ".....XXXXX", ".....XXXXX", ".....XXXXX", ".....XXXXX", ".....XXXXX" }; END_DATA }