【问题标题】:Image Blend Modes in Android Studio (Like photoshop, paint.net)?Android Studio 中的图像混合模式(如 photoshop、paint.net)?
【发布时间】:2019-01-30 10:52:18
【问题描述】:

我正在尝试以 photoshoppaint.net 混合它们的相同方式混合两个图像,使用不同的混合模式,例如 Difference, Multiply, Additive, Color Burn, Glow, etc.

我发现PorterDuff.Mode 工作得很好,但它缺乏混合效果(它只有加、乘、屏幕)有没有办法获得更大范围的混合模式?有没有办法编辑android.graphics.PorterDuff; 库以获得更多混合模式? 有什么想法吗?

例如: THIS 变成这样: Result

这是我使用 btw 的 porterduff 代码:

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;

}

【问题讨论】:

  • 你有什么合适的方法吗?

标签: android android-bitmap porter-duff blend-mode


【解决方案1】:

我并不是真正的图像处理专家,但 PorterDuff 有一些混合模式,即变暗、变亮、正片叠底、加网和叠加。然后,您可以使用 in、atop、xor 等来获得您想要的混合部分的选择。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-24
    • 2011-04-10
    相关资源
    最近更新 更多