On 2024-08-09 00:43, mick.crane wrote:
Hi,
Is this the right place to ask about Image::Imlib2 Perl code?
Blending 2 images with 100% transparent areas seems to also affect the
100% transparent areas.
I wanted to blend 2 images first and then merge them with a background
but colours went wonky so do them one at a time.
Solution for the transparent areas was to iterate over them and make
anything pure black zero alpha.
Not knowing a better way at present.
This means can't have any pixel 0,0,0 in the overlays so I'll try not
to.
#!/usr/bin/perl
use strict;
use warnings;
use feature "say";
use Image::Imlib2;
my $pens = Image::Imlib2->load("pens.png");
$pens->will_blend(0);
$pens->has_alpha(0);
my $fade=40;
do_fade("blue.png","blue_tran.png",$fade);
$fade=200;
do_fade("red.png","red_tran.png",$fade);
exit;
sub do_fade{
my ($file,$which,$f)=@_;
my $img=Image::Imlib2->load($file);
my $width = $img->width;
my $height = $img->height;
my $image = $img->create_transparent_image($f);
$image->will_blend(0);# need this to be (0)
$image->set_colour(0, 0, 0, 0);
for my $y (0 .. $height - 1) {
for my $x (0 .. $width - 1) {
my ($r, $g, $b, $a) = $image->query_pixel($x, $y);
if ($r==0 && $g==0 && $b==0){
$image->draw_point($x, $y);
}
}
}
$image->will_blend(1);
$pens->blend($image,1 , 0, 0, $width, $height, 0, 0, $width, $height);
$pens->save("$f$which");
return;
}
_______________________________________________
enlightenment-users mailing list
enlightenment-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-users