# Write an image to file
sub write {
my $self = shift;
- my %input=(jpegquality=>75, gifquant=>'mc', lmdither=>6.0, lmfixed=>[],
+ my %input=(jpegquality=>75,
+ gifquant=>'mc',
+ lmdither=>6.0,
+ lmfixed=>[],
+ idstring=>"",
+ compress=>1,
+ wierdpack=>0,
fax_fine=>1, @_);
my ($fh, $rc, $fd, $IO);
}
$self->{DEBUG} && print "writing a bmp file\n";
} elsif ( $input{type} eq 'tga' ) {
- if ( !i_writetga_wiol($self->{IMG}, $IO) ) {
+
+ if ( !i_writetga_wiol($self->{IMG}, $IO, $input{wierdpack}, $input{compress}, $input{idstring}) ) {
$self->{ERRSTR}=$self->_error_as_msg();
-# $self->{ERRSTR}='unable to write tga image';
return undef;
}
$self->{DEBUG} && print "writing a tga file\n";
}
-{
- my $got_expr;
- sub transform2 {
- my ($opts, @imgs) = @_;
-
- if (!$got_expr) {
- # this is fairly big, delay loading it
- eval "use Imager::Expr";
- die $@ if $@;
- ++$got_expr;
- }
-
- $opts->{variables} = [ qw(x y) ];
- my ($width, $height) = @{$opts}{qw(width height)};
- if (@imgs) {
- $width ||= $imgs[0]->getwidth();
- $height ||= $imgs[0]->getheight();
- my $img_num = 1;
- for my $img (@imgs) {
- $opts->{constants}{"w$img_num"} = $img->getwidth();
- $opts->{constants}{"h$img_num"} = $img->getheight();
- $opts->{constants}{"cx$img_num"} = $img->getwidth()/2;
- $opts->{constants}{"cy$img_num"} = $img->getheight()/2;
- ++$img_num;
- }
- }
- if ($width) {
- $opts->{constants}{w} = $width;
- $opts->{constants}{cx} = $width/2;
- }
- else {
- $Imager::ERRSTR = "No width supplied";
- return;
- }
- if ($height) {
- $opts->{constants}{h} = $height;
- $opts->{constants}{cy} = $height/2;
- }
- else {
- $Imager::ERRSTR = "No height supplied";
- return;
- }
- my $code = Imager::Expr->new($opts);
- if (!$code) {
- $Imager::ERRSTR = Imager::Expr::error();
- return;
- }
-
- my $img = Imager->new();
- $img->{IMG} = i_transform2($opts->{width}, $opts->{height}, $code->code(),
- $code->nregs(), $code->cregs(),
- [ map { $_->{IMG} } @imgs ]);
- if (!defined $img->{IMG}) {
- $Imager::ERRSTR = "transform2 failed";
- return;
- }
-
- return $img;
+sub transform2 {
+ my ($opts, @imgs) = @_;
+
+ require "Imager/Expr.pm";
+
+ $opts->{variables} = [ qw(x y) ];
+ my ($width, $height) = @{$opts}{qw(width height)};
+ if (@imgs) {
+ $width ||= $imgs[0]->getwidth();
+ $height ||= $imgs[0]->getheight();
+ my $img_num = 1;
+ for my $img (@imgs) {
+ $opts->{constants}{"w$img_num"} = $img->getwidth();
+ $opts->{constants}{"h$img_num"} = $img->getheight();
+ $opts->{constants}{"cx$img_num"} = $img->getwidth()/2;
+ $opts->{constants}{"cy$img_num"} = $img->getheight()/2;
+ ++$img_num;
+ }
+ }
+ if ($width) {
+ $opts->{constants}{w} = $width;
+ $opts->{constants}{cx} = $width/2;
+ }
+ else {
+ $Imager::ERRSTR = "No width supplied";
+ return;
+ }
+ if ($height) {
+ $opts->{constants}{h} = $height;
+ $opts->{constants}{cy} = $height/2;
}
+ else {
+ $Imager::ERRSTR = "No height supplied";
+ return;
+ }
+ my $code = Imager::Expr->new($opts);
+ if (!$code) {
+ $Imager::ERRSTR = Imager::Expr::error();
+ return;
+ }
+
+ my $img = Imager->new();
+ $img->{IMG} = i_transform2($opts->{width}, $opts->{height}, $code->code(),
+ $code->nregs(), $code->cregs(),
+ [ map { $_->{IMG} } @imgs ]);
+ if (!defined $img->{IMG}) {
+ $Imager::ERRSTR = Imager->_error_as_msg();
+ return;
+ }
+
+ return $img;
}
sub rubthrough {
$opts{'color'});
}
else {
- i_arc($self->{IMG},$opts{'x'},$opts{'y'},$opts{'r'},$opts{'d1'},
- $opts{'d2'},$opts{'color'});
+ # i_arc($self->{IMG},$opts{'x'},$opts{'y'},$opts{'r'},$opts{'d1'}, $opts{'d2'},$opts{'color'});
+ if ($opts{'d1'} <= $opts{'d2'}) { i_arc($self->{IMG},$opts{'x'},$opts{'y'},$opts{'r'},$opts{'d1'},$opts{'d2'},$opts{'color'}); }
+ else { i_arc($self->{IMG},$opts{'x'},$opts{'y'},$opts{'r'},$opts{'d1'}, 361,$opts{'color'});
+ i_arc($self->{IMG},$opts{'x'},$opts{'y'},$opts{'r'}, 0,$opts{'d2'},$opts{'color'}); }
}
}