gpt4 book ai didi

android - 将两个图像与乘法和 % 不透明度混合在一起

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:38:56 27 4
gpt4 key购买 nike

我正在尝试使用 Android 将两个图像混合在一起,使用类似乘法的混合模式。

// Prepare -------------------------------

// Create source images
Bitmap img1 = ...
Bitmap img2 = ...

// Create result image
Bitmap result = ...
Canvas canvas = new Canvas();
canvas.setBitmap(result);

// Get proper display reference
BitmapDrawable drawable = new BitmapDrawable(getResources(), result);
ImageView imageView = (ImageView)findViewById(R.id.imageBlend1);
imageView.setImageDrawable(drawable);


// Apply -------------------------------

// Draw base
canvas.drawBitmap(img1, 0, 0, null);

// Draw overlay
Paint paint = new Paint();
paint.setXfermode(new PorterDuffXfermode(Mode.MULTIPLY));
paint.setShader(new BitmapShader(img2, TileMode.CLAMP, TileMode.CLAMP));

canvas.drawRect(0, 0, img2.getWidth(), img2.getHeight(), paint);

这可行,但我无法控制完成的乘法“数量”——它始终是完整的乘法传输。理想情况下,0% 乘法与基本图像 (img1) 相同,没有任何变化,但 100% 乘法将是我使用上面的代码得到的结果。

paint.setAlpha() 似乎对此不起作用。

还有其他方法可以设置新“图层”的不透明度百分比吗?

附言我想有一些方法可以通过预乘和偏移颜色来使乘法与此一起工作(使用 LightingColorFilter),但它非常特定于 multiplymode ..我试图找到一种将不透明度/% 的东西也应用到所有其他传输模式的方法。

最佳答案

我刚才需要做类似的事情,我找到了 this post about Color Channels很有启发性。(但恐怕这与你在“PS”中描述的有关)

Link above in archive.org ,感谢@1j01

关于android - 将两个图像与乘法和 % 不透明度混合在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7747119/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com