私はここで壁に頭を打ちつけています、そして私は私が愚かなことをしているとかなり確信しています、それで私の愚かさを公表する時が来ました。
2つの画像を取得し、標準のブレンドアルゴリズム(ハードライト、ソフトライト、オーバーレイ、乗算など)を使用して3番目の画像にブレンドしようとしています。
Androidにはそのようなブレンドプロパティが組み込まれていないため、各ピクセルを取得し、アルゴリズムを使用してそれらを組み合わせるという道をたどりました。ただし、結果はごみです。以下は、単純な乗算ブレンドの結果です(使用された画像と期待される結果)。
ベース:
ブレンド:
期待される結果:
ゴミの結果:
どんな助けでもいただければ幸いです。以下は、私がすべての「ジャンク」を取り除こうとしたコードですが、一部は成功した可能性があります。不明な点がある場合はクリーンアップします。
ImageView imageView = (ImageView) findViewById(R.id.ImageView01);
Bitmap base = BitmapFactory.decodeResource(getResources(), R.drawable.base);
Bitmap result = base.copy(Bitmap.Config.RGB_565, true);
Bitmap blend = BitmapFactory.decodeResource(getResources(), R.drawable.blend);
IntBuffer buffBase = IntBuffer.allocate(base.getWidth() * base.getHeight());
base.copyPixelsToBuffer(buffBase);
buffBase.rewind();
IntBuffer buffBlend = IntBuffer.allocate(blend.getWidth() * blend.getHeight());
blend.copyPixelsToBuffer(buffBlend);
buffBlend.rewind();
IntBuffer buffOut = IntBuffer.allocate(base.getWidth() * base.getHeight());
buffOut.rewind();
while (buffOut.position() < buffOut.limit()) {
int filterInt = buffBlend.get();
int srcInt = buffBase.get();
int redValueFilter = Color.red(filterInt);
int greenValueFilter = Color.green(filterInt);
int blueValueFilter = Color.blue(filterInt);
int redValueSrc = Color.red(srcInt);
int greenValueSrc = Color.green(srcInt);
int blueValueSrc = Color.blue(srcInt);
int redValueFinal = multiply(redValueFilter, redValueSrc);
int greenValueFinal = multiply(greenValueFilter, greenValueSrc);
int blueValueFinal = multiply(blueValueFilter, blueValueSrc);
int pixel = Color.argb(255, redValueFinal, greenValueFinal, blueValueFinal);
buffOut.put(pixel);
}
buffOut.rewind();
result.copyPixelsFromBuffer(buffOut);
BitmapDrawable drawable = new BitmapDrawable(getResources(), result);
imageView.setImageDrawable(drawable);
}
int multiply(int in1, int in2) {
return in1 * in2 / 255;
}