Image Blend Modes in Android Studio (Like photoshop, paint.net)?

5.9k Views Asked by At

I am trying to blend two images the same way photoshop or paint.net blend them, with different blend modes like Difference, Multiply, Additive, Color Burn, Glow, etc.

I have found that PorterDuff.Mode works quite well, but it lacks blending effects ( it only has Add, Multiply, screen) is there a way to get a bigger range of blend modes? Is there a way to edit the android.graphics.PorterDuff; library to get more blend modes? Any ideas?

For example: THIS turns into this: Result

This is the porterduff code im using btw:

private static Bitmap Result(Bitmap bottomImage, Bitmap topImage){


    int sizex = bottomImage.getWidth();
    int sizey = bottomImage.getHeight();

    Paint paint = new Paint();
    Bitmap imageBitmap = Bitmap.createBitmap(sizex, sizey , Bitmap.Config.ARGB_8888);
    Canvas comboImage = new Canvas(imageBitmap);
    comboImage.drawBitmap(bottomImage, 0f, 0f, paint);;
    PorterDuff.Mode mode = PorterDuff.Mode.MULTIPLY;//Porterduff MODE
    paint.setXfermode(new PorterDuffXfermode(mode));

    Bitmap ScaledtopImage = Bitmap.createScaledBitmap(topImage, sizex, sizey, false);
    comboImage.drawBitmap(ScaledtopImage, 0f, 0f, paint);

    return imageBitmap;

}
1

There are 1 best solutions below

0
On

I'm not really an expert on image processing but PorterDuff has some blending modes, namely darken, lighten, multiply, screen and overlay. You can then use the in, atop, xor, etc to get the selection you want of the blended sections.

http://ssp.impulsetrain.com/porterduff.html https://developer.android.com/reference/android/graphics/PorterDuff.Mode