- Imager::Color's rgba() method now returns it's values as integers
instead of floating point. (IV instead of NV).
- - The XS for i_poly_aa(), i_poly_aa_cfill() and
+ - The XS for i_poly_aa(), i_poly_aa_cfill(), i_map() and
i_matrix_transform() now use the AV * typemap instead of rolling
their own.
undef_int
-i_map(im, pmaps)
+i_map(im, pmaps_av)
Imager::ImgRaw im
+ AV *pmaps_av
PREINIT:
unsigned int mask = 0;
AV *avmain;
int i, j;
unsigned char (*maps)[256];
CODE:
- if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
- croak("i_map: parameter 2 must be an arrayref\n");
- avmain = (AV*)SvRV(ST(1));
- len = av_len(avmain)+1;
+ len = av_len(pmaps_av)+1;
if (im->channels < len) len = im->channels;
maps = mymalloc( len * sizeof(unsigned char [256]) );
for (j=0; j<len ; j++) {
- temp = av_fetch(avmain, j, 0);
+ temp = av_fetch(pmaps_av, j, 0);
if (temp && SvROK(*temp) && (SvTYPE(SvRV(*temp)) == SVt_PVAV) ) {
avsub = (AV*)SvRV(*temp);
if(av_len(avsub) != 255) continue;
#!perl -w
use strict;
-use Test::More tests => 8;
+use Test::More tests => 10;
+use Imager::Test qw(is_image);
-d "testout" or mkdir "testout";
"can't map an empty image");
is($empty->errstr, "map: empty input image", "check error message");
}
+
+{ # a real map test
+ my $im = Imager->new(xsize => 10, ysize => 10);
+ $im->box(filled => 1, color => [ 255, 128, 128 ], xmax => 4, ymax => 4);
+ $im->box(filled => 1, color => [ 0, 255, 0 ], xmin => 5);
+
+ my $cmp = Imager->new(xsize => 10, ysize => 10);
+ $cmp->box(filled => 1, color => [ 127, 64, 64 ], xmax => 4, ymax => 4);
+ $cmp->box(filled => 1, color => [ 0, 127, 0 ], xmin => 5);
+ my @map = ( map int $_/2, 0 .. 255 );
+ my $out = $im->map(maps => [ \@map, \@map, \@map ]);
+ ok($out, "map()");
+ is_image($out, $cmp, "test map output");
+}