Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Blend Modes

I am looking for a way to add more advanced blend modes to my program (ones that I could define myself). How would you suggest going about this with Android?

Setting pixels individually is too slow to be a viable solution.

like image 566
Kleptine Avatar asked Sep 17 '10 04:09

Kleptine


2 Answers

It's possible even without openGL. PorterDuff should be the solution:

android.graphics.PorterDuffXfermode

and

android.graphics.PorterDuff

Here is a very good example:

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/Xfermodes.html

like image 162
Andi Krusch Avatar answered Sep 30 '22 01:09

Andi Krusch


To be honest I'm not sure this is supported. Using OpenGL as an example, the blending modes are defined by the OpenGL ES Spec, so that they can potentially be implemented in hardware. Adding your own blend function would be breaking the spec, not to mention incredibly slow, because it would have to act pixel by pixel.

I'm not so sure about canvas, but I believe that you can't do it there either, for similar reasons.

like image 42
num1 Avatar answered Sep 30 '22 02:09

num1