在我的应用程序中,我正在删除图像,我需要撤消我的擦除,因为我正在捕获屏幕并保存。虽然捕获它不会删除内容,应用程序变得缓慢。为此我想在背景中捕获但位图中的内容覆盖了最终的图像。请帮助我解决这个问题。
public void getScreen1() {
// TODO Auto-generated method stub
File myDir=new File("/sdcard/saved_images");
myDir.mkdirs();
String fname = "final-"+ n +".jpg";
File file = new File (myDir, fname);
try {
FileOutputStream ostream = new FileOutputStream(file);
if(zoomView.getZoom()==1) {
bitmapArray.compress(CompressFormat.PNG, 100, ostream);
}
else if(zoomView.getZoom()!=1) {
bitmapArray=bitmap;
bitmapArray.compress(CompressFormat.PNG, 100, ostream);
}
ostream.close();
}
catch (Exception e) {
e.printStackTrace();
}
String s="/sdcard/saved_images/"+fname;
path.add(s);
n++;
Log.i("bitmap...111",""+bitmapArray);
}
//异步任务(用于在后台运行)
class DownloadFileFromURL_dyn extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
View content = findViewById(R.id.main_container);
content.setDrawingCacheEnabled(true);
bitmapArray= content.getDrawingCache();
}
@Override
protected String doInBackground(String... f_url) {
getScreen1();
return null;
}
@Override
protected void onProgressUpdate(String... progress) {
// setting progress percentage
}
@Override
protected void onPostExecute(String file_url) {
}
}
//触摸方法上的画布
@Override
public boolean onTouchEvent(MotionEvent event) {
x = (int)event.getX();
y = (int)event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if(path.size()==0) {
String params="photo";
new DownloadFileFromURL_dyn().execute(params);
}
touch_start(x, y);
invalidate();
break;
case MotionEvent.ACTION_MOVE:
touch_move(x, y);
invalidate();
break;
case MotionEvent.ACTION_UP:
touch_up();
undo.setEnabled(true);
String params="photo";
new DownloadFileFromURL_dyn().execute(params);
invalidate();
break;
}
return true;
}