Gimp
view release on metacpan or search on metacpan
examples/iland view on Meta::CPAN
my $newimage = Gimp::Image->new($width, $height, RGB);
my $alpha = $drawable->has_alpha;
my $layer = $newimage->layer_new(
$width, $height,
$alpha ? RGBA_IMAGE : RGB_IMAGE,
"L1", 100, LAYER_MODE_NORMAL_LEGACY
);
$newimage->insert_layer($layer, 0, -1);
my $newdrawable = $newimage->get_active_drawable;
my $dest = Gimp::PixelRgn->new($newdrawable, 0, 0, $width, $height, 1, 1);
my $srcdata = $src->get_rect($drawable->bounds);
my $destdata = $srcdata->zeroes;
$destdata->slice(3) .= 255 if $alpha;
my $quant = ($srcdata->slice("($component)")->max / $delta)->floor->sclr;
goto FINISH if $quant <= 0; # nothing to do
my $destmv = $destdata->mv(0,-1); # x y rgb
Gimp::Progress->init("Rendering...");
my $relord = $width / 255;
$newdrawable->fill(FILL_FOREGROUND);
$delta = 1 if $delta < 1;
for my $x (0..$width-1) {
my $col = $srcdata->slice("($component),($x)");
my $exceed_floor = ($col > $floor);
my $r = $col->where($exceed_floor); # nvals
my $destx = ($width - $r * $relord + ($x / $elevation))->long; # nvals
#Apply elevation following the x offset in original picture
my $remain_s = zeroes(long, 3, $quant, $r->dim(0)); # xyr quant nvals
my $yslice = $remain_s->slice("(1)") .= $exceed_floor->which->dummy(0); # quant nvals
my $xslice = $remain_s->slice("(0)") .= $yslice->xvals + $destx->dummy(0); # quant nvals
my $rslice = $remain_s->slice("(2)") .= $yslice->xlinvals(0,-1) * $quant*$delta + $r->dummy(0); # quant nvals
$rslice->whereND($xslice >= $width) .= -1;
my $gt150_ind = whichND($rslice > 150);
lib/Gimp/Lib.xs view on Meta::CPAN
pdl *p = PDL->pdlnew();
PDL_Indx dims[3];
int ndims = 0;
if (c > 0) dims[ndims++] = c;
if (b > 0) dims[ndims++] = b;
if (a > 0) dims[ndims++] = a;
PDL->setdims (p, dims, ndims);
p->datatype = PDL_B;
PDL->allocdata (p);
return p;
}
static void old_pdl (pdl **p, short ndims, int dim0)
{
*p = PDL->get_convertedpdl(*p, PDL_B);
PDL->make_physical (*p);
if ((*p)->ndims < ndims + (dim0 > 1))
( run in 0.659 second using v1.01-cache-2.11-cpan-454fe037f31 )