Alphablend preserving transparency?
Hi, I need to batch process some pngs, and I'm struggling to simply put them one over another, and blend the alpha channels. Whatever I do, I end up with an image which does NOT preserve alpha values; for instance if a pixel is transparent in both images, it won't be transparent in the output. Of course, I need it to be still transparent.
Obviously I'm missing something.
Which is the way to simply put two png images one over another, and keep transparency?
Sorry to bother with such a basic question, but I didn't find the answer in the alphablending tutorial (where the result is fully opaque)...
Daniele
Ok, I have solved by re-implementing alpha compositing in jit.gen. However I'd love to know which is the standard way to solve this problem in jitter...
Thanks,
Daniele
I think it's great you solved the problem with Gen. I was going to suggest the same, since it's often easier and more clear to work things like this out in Gen than using the equivalent jit.op objects.
Hi Andrew, thanks. That is true.
However I assumed that for such a standard operation there would be a simple way to achieve it (if there is not, consider this a feature request ;-)). After all, it's just a matter of layering images one on the top of another! Something even much more intuitive and elementary than jit.+ :)
What if somebody doesn't want to re-implement alpha compositing himself?
Is there maybe a reason why jit.alphablend can't do real alpha compositing?
Thanks again,
Daniele
alphablend does exactly what it says it does, blend two images together based on the alpha value of one of them. if you need more functionality you patch it. this is max!
Hi Rob,
Jitter is amazing, and has tons of modules doing the most incredible things – however there's no easy way to layer two transparent images one on the top of another? I see your point, but in my view there's a basic object missing here. It's not jit.alphablend, I agree with you, it might be more jit.alphacomposite, or jit.layer, or whatever. That is not the point. Only you can't just say "This is Max", since Max politic (as far as I can tell) doesn't seem to be "write your own code or use gen for simple stuff". It looks like Max is becoming more and more user friendly (and I'm very happy with that!). Under this perspective, my two cents are that there's a basic module missing in jitter. That's all! And of course, that's my opinion, just a suggestion, and I will probably be wrong.
Bottomline: I don't mind writing my own alphacompositing algorithm in jit.gen, that takes 10 minutes tops. But I'm pretty sure that other people (maybe more used to Photoshop than to javascript or C or gen), in my same situation, would just drop Jitter saying "it doesn't work". User-friendliness! ;-)
d
the easiest way to alphablend images is generally to use opengl and gl.videoplane with the default @blend mode, but your milage may vary.
Hi Rob, I had already tried that. If I hadn't done something wrong, even if with gl.videoplane I can blend all the images I need, the output is completely opaque. In other words, I can superpose N images with transparency, but I'll always get all opaque pixels at the end. Am I wrong? What I wanted to do is to superpose images and still have transparency in the final result.
this is exactly what the patch above does. notice you can see the purple background color through the superimposed images where the alpha is < 1.