I'm coding a simple app which takes two images 1)Photo and 2)Filter(Image file) and then Filter will be applied on the photo. But I also want to save the Image in internal storage after the images are overlapped. As you can see in below code, in last second line I created Bitmap Object filteredPhoto so it can be used to save the image but it can't be referenced because of In-convertible types.
There are two ways,
1) Convert LayerDrawable Object to Drawable and later reference it to Bitmap Object (by casting)
2) Convert LayerDrawable directly to Bitmap if possible.
Can anyone explain me how to make this happen?
Note : This question may have been asked by others but none of them has replied them properly. Most of them said use Canvas but I can't find how Canvas can help me in my problem so kindly don't mark my question as Duplicate.
Code :
@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");
}