- added inline_replace_color.pl to samples
- constify the Imager API
- document Imager::Filter::Mandelbrot
+- convert dynfilt/flines.c to Imager::Filter::Flines
=================================================================
--- /dev/null
+package Imager::Filter::Flines;
+use strict;
+use Imager;
+use vars qw($VERSION @ISA);
+
+BEGIN {
+ $VERSION = "0.01";
+
+ eval {
+ require XSLoader;
+ XSLoader::load('Imager::Filter::Flines', $VERSION);
+ 1;
+ } or do {
+ require DynaLoader;
+ push @ISA, 'DynaLoader';
+ bootstrap Imager::Filter::Flines $VERSION;
+ };
+}
+
+Imager->register_filter(type=>'flines',
+ callsub => sub { my %hsh = @_; flines($hsh{image}) },
+ defaults => {},
+ callseq => [ 'image' ] );
+
+1;
+
+__END__
+
+=head1 NAME
+
+Imager::Filter::Flines - dim alternate lines to emulate a video display
+
+=head1 SYNOPSIS
+
+ use Imager;
+ use Imager::Filter::Flines;
+
+ $img->filter(type=>'flines');
+
+=head1 DESCRIPTION
+
+This is an adaption of the flines dynamically loadable filter
+provided in dynfilt/ in previous releases of Imager.
+
+This filter has no parameters.
+
+=head1 AUTHOR
+
+Original by Arnar M. Hrafnkelsson.
+
+Adapted by Tony Cook <tony@imager.perl.org>
+
+=head1 SEE ALSO
+
+Imager, Imager::Filters.
+
+=cut
--- /dev/null
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+#include "ppport.h"
+#ifdef __cplusplus
+}
+#endif
+
+#include "imext.h"
+#include "imperl.h"
+
+unsigned char
+static
+saturate(int in) {
+ if (in>255) { return 255; }
+ else if (in>0) return in;
+ return 0;
+}
+
+
+
+void
+flines(i_img *im) {
+ i_color vl;
+ int i,bytes,x,y;
+ int idx;
+
+
+ for(y = 0; y < im->ysize; y ++) {
+ for(x = 0; x < im->xsize; x ++ ) {
+ i_gpix(im,x,y,&vl);
+ if (!(y%2)) {
+ float yf = y/(float)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)/(float)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);
+ }
+ }
+}
+
+
+DEFINE_IMAGER_CALLBACKS;
+
+MODULE = Imager::Filter::Flines PACKAGE = Imager::Filter::Flines
+
+void
+flines(im)
+ Imager::ImgRaw im
+
+BOOT:
+ PERL_INITIALIZE_IMAGER_CALLBACKS;
+
--- /dev/null
+use ExtUtils::MakeMaker;
+require "../metafile.pl";
+
+my %opts =
+ (
+ NAME => 'Imager::Filter::Flines',
+ VERSION_FROM => 'Flines.pm',
+ OBJECT => 'Flines.o',
+ INC => '-I..'
+ );
+if ($ExtUtils::MakeMaker::VERSION > 6.06) {
+ $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>';
+ $opts{ABSTRACT} = 'Flines Imager filter extension';
+}
+
+WriteMakefile(%opts);
+
+
--- /dev/null
+#!perl -w
+use strict;
+use blib;
+use lib '../t';
+use Imager;
+use Test::More tests => 3;
+
+BEGIN { use_ok('Imager::Filter::Flines') }
+
+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");
DynTest/Makefile.PL
DynTest/linstretch.c
DynTest/t/t00dyntest.t
+Flines/Flines.pm
+Flines/Flines.xs
+Flines/Makefile.PL
+Flines/t/t00flines.t
Imager.pm
Imager.xs
MANIFEST
\.o$
^testout
^blib/
+^Flines/Flines\.c$
^Imager\.c$
^Mandelbrot/Mandelbrot\.c$
^CountColor/CountColor\.c$