I am using this demo to imnplement the paint in my application. This Demo.
Now i want Image as a Background of the paint. after that the paint done on that image should be erased as like the it has functionality right now for paint. And while i save that image then it should be save with that Image.
So What should i have to do for that ??
Updated:
Save code:
case PHOTO_SAVE:
final Activity currentActivity = this;
Handler saveHandler = new Handler(){
@Override
public void handleMessage(Message msg) {
final AlertDialog alertDialog = new AlertDialog.Builder(currentActivity).create();
alertDialog.setTitle("Drawing App");
alertDialog.setMessage("Your drawing is saved. :)");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
}
});
alertDialog.show();
}
} ;
System.out.println("1");
new ExportBitmapToFile(this,saveHandler, mBitmap).execute();
System.out.println("2");
return true;
And the ExportBitmapToFile class is:
private class ExportBitmapToFile extends AsyncTask<Intent,Void,Boolean> {
private Context mContext;
private Handler mHandler;
private Bitmap nBitmap;
private ProgressDialog m_progressDialog = null;
@Override
protected void onPreExecute(){
m_progressDialog = new ProgressDialog(mContext);
m_progressDialog.setTitle("Drawing App");
m_progressDialog.setMessage("Please wait...");
m_progressDialog.setCancelable(false);
m_progressDialog.show();
System.out.println("3");
}
public ExportBitmapToFile(Context context,Handler handler,Bitmap bitmap) {
mContext = context;
nBitmap = bitmap;
mHandler = handler;
}
@Override
protected Boolean doInBackground(Intent... arg0) {
try {
if (!APP_FILE_PATH.exists()) {
APP_FILE_PATH.mkdirs();
}
System.out.println("4");
final FileOutputStream out = new FileOutputStream(new File(APP_FILE_PATH + "/"+filename+".jpg"));
nBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
System.out.println("5");
out.flush();
out.close();
return true;
}catch (Exception e) {
e.printStackTrace();
}
//mHandler.post(completeRunnable);
return false;
}
@Override
protected void onPostExecute(Boolean bool) {
super.onPostExecute(bool);
if ( bool ){
mHandler.sendEmptyMessage(1);
}
if (m_progressDialog.isShowing()) {
m_progressDialog.dismiss();
}
}
}
A Small Change.
where
mBackgroundis aBitmapyou initialize in the Constructor ofMyView.I’m pretty sure, that should do, if you have any problems do report back.
Update : See Comments
In That Case, forget the above changes, and modify the
onDrawMethod like this.While saving, You’ll have to overlay both Bitmaps onto a new Bitmap Object and then finally write it to disk.
To Overlap both Bitmaps,