-1
我們如何可以在兩個影像合成並在Android中 保存喜歡這個程序:https://lh3.ggpht.com/kqSKzLzKvtGZxw2DmSLTyVvRUaX1whq8z89X7Rj9XFGt2zOkMXWXyZyDkND3Yq56k80=h900-rw我們如何可以在兩個圖像疊加並保存在Android中
我們如何可以在兩個影像合成並在Android中 保存喜歡這個程序:https://lh3.ggpht.com/kqSKzLzKvtGZxw2DmSLTyVvRUaX1whq8z89X7Rj9XFGt2zOkMXWXyZyDkND3Yq56k80=h900-rw我們如何可以在兩個圖像疊加並保存在Android中
您可以在Android的佈局保存爲形象的比方:
RelativeLayout view;
view.setDrawingCacheEnabled(true);
view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.buildDrawingCache(true);
Bitmap b = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false); // clear draFwing cache
bmImage.setImageBitmap(b);
saveImage();
public void saveImage() {
BitmapDrawable drawable = (BitmapDrawable) bmImage.getDrawable();
Bitmap bitmap = drawable.getBitmap();
File sdCardDirectory = Environment.getExternalStorageDirectory();
File image = new File(sdCardDirectory, "my_card.png");
boolean success = false;
FileOutputStream outStream;
try {
outStream = new FileOutputStream(image);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
/* 100 to keep full quality of the image */
outStream.flush();
outStream.close();
success = true;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (success) {
Toast.makeText(getApplicationContext(), "Image saved with success",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(),
"Error during image saving", Toast.LENGTH_LONG).show();
}
}