1) 写真と 2) フィルター (画像ファイル) の 2 つの画像を取得し、写真にフィルターが適用される単純なアプリをコーディングしています。しかし、画像が重なった後、画像を内部ストレージに保存したいです。以下のコードでわかるように、最後の 2 行目で Bitmap オブジェクトを作成filteredPhoto
したため、画像の保存に使用できますが、変換できない型のため参照できません。
2つの方法があります。
1)LayerDrawable
オブジェクトを変換しDrawable
、後でビットマップオブジェクトに参照します(キャストによる)
2)LayerDrawable
可能であれば直接変換しBitmap
ます。
誰かがこれを実現する方法を説明できますか?
注 : この質問は他の人から寄せられた可能性がありますが、適切に回答した人はいません。彼らのほとんどは使用すると言いましたが、私の問題を解決するCanvas
方法が見つからないので、私の質問を重複としてマークしないでください。Canvas
コード :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
theImageViewMID = (ImageView) findViewById(R.id.theImageView_MID);
Drawable layers[] = new Drawable[2];
layers[0] = ContextCompat.getDrawable(this, R.drawable.image_1546);
layers[1] = ContextCompat.getDrawable(this, R.drawable.new_filter);
layers[1].setAlpha(75);
LayerDrawable layerDrawable = new LayerDrawable(layers);
theImageViewMID.setImageDrawable(layerDrawable);
layerDrawable.set
Bitmap filteredPhoto = ((BitmapDrawable) LayerDrawable).getBitmap();
//MediaStore.Images.Media.insertImage(getContentResolver(), filteredPhoto, "THIS IS TITLE", "THIS IS DESCRIPTION");
}