问题
is it possible to make the save image as the new background so that when I add a new image it will be combined with the previously added image? Please help me again, thank you :)
here is the code. on the button flatimage it flattened the combined background, sticker and image and it will put on the ImageView, Once it is put on the imageview I want it to be the background image and I am able to add more stickers and flat it again as 1 bitmapimage. please help me thank you
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.createpage1);
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss",
Locale.getDefault()).format(new Date());
mTempDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/" + "PixiePhotos" + "/";
//mCurrent = "PXD_" + timeStamp + ".jpg";
prepareDirectory();
save = (Button)findViewById(R.id.save);
flatimage = (Button)findViewById(R.id.flatimage);
chooseimage = (Button)findViewById(R.id.chooseImage);
compositeImageView = (ImageView)findViewById(R.id.compositeImageView);
tapimageview = (ImageView) findViewById(R.id.tapimageview);
// imageView5 = (ImageView)findViewById(R.id.imageView5);
imageView4 = (ImageView) findViewById(R.id.imageView4);
imageView4.setOnTouchListener(this);
tapimageview.setImageURI(Uri.parse("android.resource://"
+ getPackageName() +"/"+R.drawable.cork));
compositeImageView.setOnTouchListener(this);
chooseimage.setOnClickListener(this);
imageView4.setImageBitmap(drawingBitmap);
//tapimageview.setDrawingCacheEnabled(true);
//bgimage = tapimageview.getDrawingCache();
viewBitmap = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888);
canvas = new Canvas(viewBitmap);
tapimageview.draw(canvas);
// tapimageview.draw(canvas);
//canvas.drawBitmap(bmp, 90, 0, paint);
flatimage.setOnClickListener(new View.OnClickListener() {
@SuppressWarnings("deprecation")
public void onClick(View v) {
Log.v(TAG, "Save Tab Clicked");
//i is imageview whch u want to convert in bitmap
canvas.drawBitmap(bmp, 0, 0, paint);
canvas.drawBitmap(drawingBitmap, matrix, paint);
canvas.drawBitmap(bmpstickers, matrix, paint);
mBitmapDrawable = new BitmapDrawable(viewBitmap);
tapimageview.setImageBitmap(mBitmapDrawable.getBitmap());
mCurrent = "PXD_" + new SimpleDateFormat("yyyyMMdd_HHmmss",
Locale.getDefault()).format(new Date()) + ".jpg";
}
});
save.setOnClickListener(new View.OnClickListener() {
@SuppressWarnings("deprecation")
public void onClick(View v) {
Log.v(TAG, "Save Tab Clicked");
viewBitmap = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888);//i is imageview whch u want to convert in bitmap
canvas = new Canvas(viewBitmap);
tapimageview.draw(canvas);
canvas.drawBitmap(bmp, 0, 0, paint);
canvas.drawBitmap(drawingBitmap, matrix, paint);
canvas.drawBitmap(bmpstickers, matrix, paint);
tapimageview.setImageBitmap(mBitmapDrawable.getBitmap());
try {
mBitmapDrawable = new BitmapDrawable(viewBitmap);
mCurrent = "PXD_" + new SimpleDateFormat("yyyyMMdd_HHmmss",
Locale.getDefault()).format(new Date()) + ".jpg";
mNewSaving = ((BitmapDrawable) mBitmapDrawable).getBitmap();
String FtoSave = mTempDir + mCurrent;
File mFile = new File(FtoSave);
mFileOutputStream = new FileOutputStream(mFile);
mNewSaving.compress(CompressFormat.JPEG, 100, mFileOutputStream);
mFileOutputStream.flush();
mFileOutputStream.close();
} catch (FileNotFoundException e) {
Log.v(TAG, "FileNotFoundExceptionError " + e.toString());
} catch (IOException e) {
Log.v(TAG, "IOExceptionError " + e.toString());
}
}
});
}
来源:https://stackoverflow.com/questions/21917657/how-to-put-another-image-on-the-saved-bitmap