I'm creating an application for placing one image view on the another image view and made to single image and save into SD card. I run the application it creates image and save to SD card but this image is blank. Both images are not showing on one single image which is save in the SD card.
Here is my code.
@SuppressWarnings("deprecation")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ImageView image2 = (ImageView) findViewById(R.id.ImageViewTwo);
final ImageView image = (ImageView) findViewById(R.id.ImageViewOne);
mTempDir = Environment.getExternalStorageDirectory()+"/"+"TestTemp";
File mtempFile = new File(mTempDir);
if(!mtempFile.exists())
{
mtempFile.mkdir();
}
mSaveImageName = "Test.png";
mBackGround = Bitmap.createBitmap(100 , 100 ,Bitmap.Config.ARGB_8888);
image2.buildDrawingCache();
mBackImage = image2.getDrawingCache();
mBackImage = Bitmap.createBitmap(100 , 100 ,Bitmap.Config.ARGB_8888);
image.buildDrawingCache();
mTopImage = image.getDrawingCache();
mTopImage = Bitmap.createBitmap(100 , 100 , Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(mBackGround);
//mCanvas.drawBitmap(mBackImage, (mCanvas.getWidth() / 2), 0, null);
mCanvas.drawBitmap(mBackImage ,0f , 0f , null);
mCanvas.drawBitmap(mTopImage, 12f , 12f , null);
try
{
mBitmapDrawable = new BitmapDrawable(mBackGround);
Bitmap mNewSaving = mBitmapDrawable .getBitmap();
String ftoSave = mTempDir + mSaveImageName;
File mFile = new File(ftoSave);
mFileOutputStream = new FileOutputStream(mFile);
mNewSaving.compress(CompressFormat.PNG, 95 , mFileOutputStream);
mFileOutputStream.flush();
mFileOutputStream.close();
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.i(TAG, "Image Created");
}