简体   繁体   中英

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

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;

}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM