CPAN::Meta::YAML are available.
https://rt.cpan.org/Ticket/Display.html?id=69008
+ - hoist the per-line calculations for the flines implementations, and
+ modernize the tests a bit.
+ https://rt.cpan.org/Ticket/Display.html?id=70126
+
Imager 0.84_01 - 8 Aug 2011
==============
return 0;
}
-
-
-void
+static void
flines(i_img *im) {
i_color vl;
i_img_dim x,y;
-
+
for(y = 0; y < im->ysize; y ++) {
+ float yf, mf;
+ if (!(y%2)) {
+ yf = y/(double)im->ysize;
+ }
+ else {
+ yf = (im->ysize-y)/(double)im->ysize;
+ }
+ mf = 1.2-0.8*yf;
+
for(x = 0; x < im->xsize; x ++ ) {
i_gpix(im,x,y,&vl);
- if (!(y%2)) {
- float yf = y/(double)im->ysize;
- float mf = 1.2-0.8*yf;
- vl.rgb.r = saturate(vl.rgb.r*mf);
- vl.rgb.g = saturate(vl.rgb.g*mf);
- vl.rgb.b = saturate(vl.rgb.b*mf);
- } else {
- float yf = (im->ysize-y)/(double)im->ysize;
- float mf = 1.2-0.8*yf;
- vl.rgb.r = saturate(vl.rgb.r*mf);
- vl.rgb.g = saturate(vl.rgb.g*mf);
- vl.rgb.b = saturate(vl.rgb.b*mf);
- }
- i_ppix(im,x,y,&vl);
+ vl.rgb.r = saturate(vl.rgb.r*mf);
+ vl.rgb.g = saturate(vl.rgb.g*mf);
+ vl.rgb.b = saturate(vl.rgb.b*mf);
+ i_ppix(im,x,y,&vl);
}
}
}
BEGIN { use_ok('Imager::Filter::Flines') }
-my $im = Imager->new(xsize=>150, ysize=>150);
+-d "testout" or mkdir "testout";
-$im->box(filled=>1, xmin => 70, ymin=>25, xmax =>130, ymax => 125,
- color=>'00FF00');
-$im->box(filled=>1, xmin=>20, ymin=>25, xmax=>80, ymax=>125,
- color => '0000FF');
-$im->arc(x =>75, y=>75, r=>30, color => 'FF0000');
-$im->filter(type=>"conv", coef => [0.1, 0.2, 0.4, 0.2, 0.1]);
+Imager->open_log(log => "testout/t00flines.log");
-ok($im->filter(type=>'flines'),
- "try filter")
- or print "# ", $im->errstr, "\n";
-ok($im->write(file => '../testout/t00flines.ppm'),
- "save result");
+{
+ my $im = Imager->new(xsize=>150, ysize=>150);
+
+ $im->box(filled=>1, xmin => 70, ymin=>25, xmax =>130, ymax => 125,
+ color=>'00FF00');
+ $im->box(filled=>1, xmin=>20, ymin=>25, xmax=>80, ymax=>125,
+ color => '0000FF');
+ $im->arc(x =>75, y=>75, r=>30, color => 'FF0000');
+ $im->filter(type=>"conv", coef => [0.1, 0.2, 0.4, 0.2, 0.1]);
+
+ ok($im->filter(type=>'flines'),
+ "try filter")
+ or print "# ", $im->errstr, "\n";
+ ok($im->write(file => 'testout/t00flines.ppm'),
+ "save result");
+}
+
+END {
+ Imager->close_log;
+
+ unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink 'testout/t00flines.ppm';
+ unlink "testout/t00flines.log";
+ rmdir "testout";
+ }
+}
i_DFcp(im->xsize,im->ysize), im->channels);
for(y = 0; y < im->ysize; y ++) {
+ float yf, mf;
+ if (!(y%2)) {
+ yf = y/(double)im->ysize;
+ }
+ else {
+ yf = (im->ysize-y)/(double)im->ysize;
+ }
+ mf = 1.2-0.8*yf;
+
for(x = 0; x < im->xsize; x ++ ) {
i_gpix(im,x,y,&vl);
- if (!(y%2)) {
- float yf = y/(double)im->ysize;
- float mf = 1.2-0.8*yf;
- vl.rgb.r = saturate(vl.rgb.r*mf);
- vl.rgb.g = saturate(vl.rgb.g*mf);
- vl.rgb.b = saturate(vl.rgb.b*mf);
- } else {
- float yf = (im->ysize-y)/(double)im->ysize;
- float mf = 1.2-0.8*yf;
- vl.rgb.r = saturate(vl.rgb.r*mf);
- vl.rgb.g = saturate(vl.rgb.g*mf);
- vl.rgb.b = saturate(vl.rgb.b*mf);
- }
- i_ppix(im,x,y,&vl);
+ vl.rgb.r = saturate(vl.rgb.r*mf);
+ vl.rgb.g = saturate(vl.rgb.g*mf);
+ vl.rgb.b = saturate(vl.rgb.b*mf);
+ i_ppix(im,x,y,&vl);
}
}
}
#!perl -w
use strict;
use lib '../t';
-use Test::More tests => 4;
+use Test::More tests => 8;
BEGIN { use_ok(Imager => qw(:default)); }
use Config;
+use Imager::Test qw(test_image);
#$Imager::DEBUG=1;
-Imager::init('log'=>'../testout/t60dyntest.log');
+-d "testout" or mkdir "testout";
+
+Imager->open_log(log => 'testout/t60dyntest.log');
my $img=Imager->new() || die "unable to create image object\n";
my %hsh=(a=>35,b=>200,type=>'lin_stretch');
ok($img->filter(%hsh), "call filter");
-$img->write(type=>'pnm',file=>'../testout/t60.ppm')
+$img->write(type=>'pnm',file=>'testout/linstretch.ppm')
|| die "error in write()\n";
ok(unload_plugin($plug), "unload plugin")
|| die "unable to unload plugin: $Imager::ERRSTR\n";
-
+{
+ my $flines = "./flines.$Config{so}";
+ ok(load_plugin($flines), "load flines");
+ my $im = test_image();
+ ok($im->filter(type => "flines"), "do the flines test");
+ ok($im->write(file => "testout/flines.ppm"), "save flines result");
+ ok(unload_plugin($flines), "unload flines");
+}
+
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink "testout/linstretch.ppm";
+ unlink "testout/flines.ppm";
+ unlink "testout/t60dyntest.log";
+ rmdir "testout";
+}