- removed all references to the www.eecs.umich.edu page and changed
them to imager.perl.org ones.
+0.43pre1
+ - added log() and exp() functions to transform2()
+ - change the getpN() functions in transform2() to set a
+ reasonable alpha if the input image has no alpha
+ - document the constants that transform2() defines
+
=================================================================
For latest versions check the Imager-devel pages:
use constant RBC_RGBA => 46;
use constant RBC_HSVA => 47;
use constant RBC_ALPHA => 48;
-use constant RBC_OP_COUNT => 49;
+use constant RBC_LOG => 49;
+use constant RBC_EXP => 50;
+use constant RBC_OP_COUNT => 51;
-@EXPORT = qw(RBC_ADD RBC_SUBTRACT RBC_MULT RBC_DIV RBC_MOD RBC_POW RBC_UMINUS RBC_MULTP RBC_ADDP RBC_SUBTRACTP RBC_SIN RBC_COS RBC_ATAN2 RBC_SQRT RBC_DISTANCE RBC_GETP1 RBC_GETP2 RBC_GETP3 RBC_VALUE RBC_HUE RBC_SAT RBC_HSV RBC_RED RBC_GREEN RBC_BLUE RBC_RGB RBC_INT RBC_IF RBC_IFP RBC_LE RBC_LT RBC_GE RBC_GT RBC_EQ RBC_NE RBC_AND RBC_OR RBC_NOT RBC_ABS RBC_RET RBC_JUMP RBC_JUMPZ RBC_JUMPNZ RBC_SET RBC_SETP RBC_PRINT RBC_RGBA RBC_HSVA RBC_ALPHA RBC_OP_COUNT);
+@EXPORT = qw(RBC_ADD RBC_SUBTRACT RBC_MULT RBC_DIV RBC_MOD RBC_POW RBC_UMINUS RBC_MULTP RBC_ADDP RBC_SUBTRACTP RBC_SIN RBC_COS RBC_ATAN2 RBC_SQRT RBC_DISTANCE RBC_GETP1 RBC_GETP2 RBC_GETP3 RBC_VALUE RBC_HUE RBC_SAT RBC_HSV RBC_RED RBC_GREEN RBC_BLUE RBC_RGB RBC_INT RBC_IF RBC_IFP RBC_LE RBC_LT RBC_GE RBC_GT RBC_EQ RBC_NE RBC_AND RBC_OR RBC_NOT RBC_ABS RBC_RET RBC_JUMP RBC_JUMPZ RBC_JUMPNZ RBC_SET RBC_SETP RBC_PRINT RBC_RGBA RBC_HSVA RBC_ALPHA RBC_LOG RBC_EXP RBC_OP_COUNT);
%Attr = (
'setp' => {
'func' => 1,
'types' => 'p'
},
+ 'log' => {
+ 'result' => 'r',
+ 'parms' => 1,
+ 'opcode' => 49,
+ 'func' => 1,
+ 'types' => 'r'
+ },
'hsva' => {
'result' => 'p',
'parms' => 4,
'op_count' => {
'result' => undef,
'parms' => 0,
- 'opcode' => 49,
+ 'opcode' => 51,
'func' => 0,
'types' => ''
},
'func' => 0,
'types' => 'rr'
},
+ 'exp' => {
+ 'result' => 'r',
+ 'parms' => 1,
+ 'opcode' => 50,
+ 'func' => 1,
+ 'types' => 'r'
+ },
'subtract' => {
'result' => 'r',
'parms' => 2,
=head1 SEE ALSO
-perl(1), Imager(3), http://www.eecs.umich.edu/~addi/perl/Imager/
+perl(1), Imager(3), http://imager.perl.org/~addi/perl/Imager/
=cut
[ 1, 0, 0 ],
[ 0, 0, 1 ] ]);
+ # image composition
+ $img->compose(img=>$source, mask=>$mask, left=>100, top=>50)
+ or die $img->errstr;
+
# limit the range of red channel from 0..255 to 0..127
@map = map { int( $_/2 } 0..255;
$img->map( red=>\@map );
#include "regmach.h"
+#include <float.h>
/*#define DEBUG*/
#ifdef DEBUG
#define DBG(x)
#endif
+static float MAX_EXP_ARG; /* = log(DBL_MAX); */
+
+
/* these functions currently assume RGB images - there seems to be some
support for other color spaces, but I can't tell how you find what
space an image is using.
double dx, dy;
struct rm_op *codes_base = codes;
size_t count_base = code_count;
+
DBG(("rm_run(%p, %d)\n", codes, code_count));
while (code_count) {
DBG((" rm_code %d\n", codes->code));
case rbc_getp1:
i_gpix(images[0], na, nb, c_regs+codes->rout);
+ if (images[0]->channels < 4) cout.rgba.a = 255;
break;
case rbc_getp2:
i_gpix(images[1], na, nb, c_regs+codes->rout);
+ if (images[1]->channels < 4) cout.rgba.a = 255;
break;
case rbc_getp3:
i_gpix(images[2], na, nb, c_regs+codes->rout);
+ if (images[2]->channels < 4) cout.rgba.a = 255;
break;
case rbc_value:
cout = ca;
break;
+ case rbc_log:
+ if (na > 0) {
+ nout = log(na);
+ }
+ else {
+ nout = DBL_MAX;
+ }
+ break;
+
+ case rbc_exp:
+ if (!MAX_EXP_ARG) MAX_EXP_ARG = log(DBL_MAX);
+ if (na <= MAX_EXP_ARG) {
+ nout = exp(na);
+ }
+ else {
+ nout = DBL_MAX;
+ }
+ break;
+
case rbc_print:
printf("r%d is %g\n", codes->ra, na);
break;
rbc_rgba, /* rgba(ra, rb, rc, rd) -> p */
rbc_hsva, /* hsva(ra, rb, rc, rd) -> p */
rbc_alpha, /* alpha(pa) -> r */
+ rbc_log, /* log(ra) -> r */
+ rbc_exp, /* exp(ra) -> r */
rbc_op_count
};
#!perl -w
-BEGIN { $| = 1; print "1..15\n"; }
+BEGIN { $| = 1; print "1..16\n"; }
END {print "not ok 1\n" unless $loaded;}
use Imager;
$c = $im8->getpixel(x=>49, 'y'=>49);
is(($c->rgba)[3], 255, "max alpha");
+$opts = { rpnexpr => 'x 1 + log 50 * y 1 + log 50 * getp1' };
+my $im9 = Imager::transform2($opts, $im1);
+ok($im9, "log function");
+if ($im9) {
+ $im9->write(type=>'pnm', file=>'testout/t56-9.ppm');
+}
+
use Imager::Transform;
# some simple tests