tapimageview
是我想在单击保存图像后显示 mBitmapDrawable
的 ImageView
。我做的对吗?
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);
try {
mBitmapDrawable = new BitmapDrawable(viewBitmap);
tapimageview.setImageMatrix(mBitmapDrawable);
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());
}
}
});
}
最佳答案
这可能是您正在寻找的东西吗?
tapimageview.setImageBitmap(mBitmapDrawable.getBitmap());
关于android - 如何将 BitmapDrawable 设置到 ImageView 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21916565/