Added methods gsresolution and finalresolution to adjust intermediate
and final resolution of pixmap output.
This commit is contained in:
parent
a23fcb5862
commit
e231f5e307
|
@ -27,7 +27,7 @@ use Data::Dumper;
|
|||
use HTTP::Date qw(parse_date);
|
||||
use Time::Local qw(timegm_nocheck);
|
||||
|
||||
$VERSION = do { my @r=(q$Revision: 1.9 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r};
|
||||
$VERSION = do { my @r=(q$Revision: 1.10 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r};
|
||||
|
||||
=head2 new(%opts)
|
||||
|
||||
|
@ -64,8 +64,10 @@ sub new {
|
|||
bless ($self, $class);
|
||||
|
||||
$self->{data} = [];
|
||||
$self->{style} = "lines";
|
||||
$self->{output_format} = "png";
|
||||
$self->{style} = $opts{style} || "lines";
|
||||
$self->{output_format} = $opts{output_format} || "png";
|
||||
$self->{gsresolution} = $opts{gsresolution} || 150;
|
||||
$self->finalresolution($opts{finalresolution} || 75);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -191,6 +193,50 @@ sub output_format {
|
|||
return $oldoutput_format;
|
||||
}
|
||||
|
||||
=head2 gsresolution([$gsresolution])
|
||||
|
||||
Sets the resolution of the ghostscript output when plotting to a pixmap
|
||||
format. The previous resolution is returned.
|
||||
|
||||
See new() for details about output formats.
|
||||
|
||||
=cut
|
||||
|
||||
sub gsresolution {
|
||||
my ($self, $gsresolution) = @_;
|
||||
my $oldgsresolution = $self->{gsresolution};
|
||||
$self->{gsresolution} = $gsresolution if ($gsresolution);
|
||||
return $oldgsresolution;
|
||||
}
|
||||
|
||||
|
||||
=head2 finalresolution([$finalresolution])
|
||||
|
||||
Sets the resolution when plotting to a pixmap
|
||||
format. The previous resolution is returned.
|
||||
|
||||
If this resolution is higher than the gsresolution, gsresolution is set
|
||||
the same value. If it is higher than half of the gsresolution then the
|
||||
gsresolution is set to twice the finalresolution.
|
||||
|
||||
See new() for details about output formats.
|
||||
|
||||
=cut
|
||||
|
||||
sub finalresolution {
|
||||
my ($self, $finalresolution) = @_;
|
||||
my $oldfinalresolution = $self->{finalresolution};
|
||||
if (defined($finalresolution)) {
|
||||
$self->{finalresolution} = $finalresolution if ($finalresolution);
|
||||
if ($finalresolution >= $self->{gsresolution}) {
|
||||
$self->{gsresolution} = $finalresolution;
|
||||
} elsif ($finalresolution >= $self->{gsresolution} / 2) {
|
||||
$self->{gsresolution} = $finalresolution * 2;
|
||||
}
|
||||
}
|
||||
return $oldfinalresolution;
|
||||
}
|
||||
|
||||
|
||||
|
||||
=head2 dstcorr $time [, $period]
|
||||
|
@ -453,9 +499,11 @@ sub plot {
|
|||
if ($self->{output_format} eq "ps") {
|
||||
$pipe = "< $psfn";
|
||||
} else {
|
||||
$pipe =
|
||||
"gs -sDEVICE=ppmraw -r150 -dBATCH -sOutputFile=- -q - < $psfn |" .
|
||||
"pnmscale 0.5 |" .
|
||||
$pipe = "gs -sDEVICE=ppmraw -r" . $self->{gsresolution} . " -dBATCH -sOutputFile=- -q - < $psfn |";
|
||||
if ($self->{gsresolution} != $self->{finalresolution}) {
|
||||
$pipe .= "pnmscale " . ($self->{finalresolution} / $self->{gsresolution}) . " |";
|
||||
}
|
||||
$pipe .=
|
||||
"pnmflip -cw |" .
|
||||
"pnmcrop 2> /dev/null |";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue