- expand documentation of scaleX()/scaleY()
- rotate()s back parameter now accepts color names like other methods
- convert t/t69rubthru.t to Test::More
+- minor clean up of rubthrough() method
+- error handling tests for rubthrough()
=================================================================
my $self=shift;
my %opts=(tx => 0,ty => 0, @_);
- unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
- unless ($opts{src} && $opts{src}->{IMG}) { $self->{ERRSTR}='empty input image for source'; return undef; }
+ unless ($self->{IMG}) {
+ $self->{ERRSTR}='empty input image';
+ return undef;
+ }
+ unless ($opts{src} && $opts{src}->{IMG}) {
+ $self->{ERRSTR}='empty input image for src';
+ return undef;
+ }
%opts = (src_minx => 0,
src_miny => 0,
%opts);
unless (i_rubthru($self->{IMG}, $opts{src}->{IMG}, $opts{tx}, $opts{ty},
- $opts{src_minx}, $opts{src_miny}, $opts{src_maxx}, $opts{src_maxy})) {
- $self->{ERRSTR} = $self->_error_as_msg();
+ $opts{src_minx}, $opts{src_miny},
+ $opts{src_maxx}, $opts{src_maxy})) {
+ $self->_set_error($self->_error_as_msg());
return undef;
}
return $self;
#!perl -w
use strict;
-use Test::More tests => 23;
+use Test::More tests => 28;
BEGIN { use_ok(Imager => qw(:all :handy)); }
init_log("testout/t69rubthru.log", 1);
my $oogtarg = Imager->new(xsize=>100, ysize=>100, channels=>1);
ok(!$oogtarg->rubthrough(src=>$oosrc), "check oo fails correctly");
+is($oogtarg->errstr,
+ 'rubthru can only work where (dest, src) channels are (3,4), (3,2) or (1,2)',
+ "check error message");
+
+{ # check empty image errors
+ my $empty = Imager->new;
+ ok(!$empty->rubthrough(src => $oosrc), "check empty target");
+ is($empty->errstr, 'empty input image', "check error message");
+ ok(!$oogtarg->rubthrough(src=>$empty), "check empty source");
+ is($oogtarg->errstr, 'empty input image for src',
+ "check error message");
+}
+
sub color_cmp {
my ($l, $r) = @_;
my @l = $l->rgba;