我还有另一种看法:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="350dp"
android:layout_height="350dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="140dp"
android:layout_height="match_parent"
android:layout_marginRight="2.5dp"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="2.5dp"
android:layout_weight="1"
android:longClickable="true"
android:scaleType="matrix"
android:src="@drawable/a1" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="2.5dp"
android:layout_weight="1"
android:longClickable="true"
android:scaleType="matrix"
android:src="@drawable/a2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginLeft="2.5dp"
android:longClickable="true"
android:scaleType="matrix"
android:src="@drawable/a4" />
</LinearLayout>
</LinearLayout>看上去:

在此视图中,用户可以编辑此图片的查看(缩放、旋转)。
我得保存编辑好的照片拼贴。如何用缩放和旋转的照片保存视图?是否可以将位图中的编辑视图保存到应用程序缓存中?
谢谢你的帮助!
发布于 2015-01-17 13:32:51
是的,您可以简单地获取编辑图像的屏幕截图,并创建一个位图,该位图可以保存在任何您想要的位置。
下面是获取位图的函数
public Bitmap getBitMap() {
try {
yourEditedPhotoCollageLayout.buildDrawingCache();
Bitmap bmp = Bitmap.createBitmap(yourEditedPhotoCollageLayout.getDrawingCache());
return bmp;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}这样你就可以保存那个位图
private void saveBitmap(Bitmap bitmap) {
try {
File storageDir = createImageFile();
String path = storageDir.toString();
OutputStream out = new FileOutputStream(path);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.close();
MyMediaConnectorClient client = new MyMediaConnectorClient(path);
MediaScannerConnection scanner = new MediaScannerConnection(
Context, client);
client.setScanner(scanner);
scanner.connect();
} catch (IOException e) {
Log.e("save image", "failed to save image", e);
}
}https://stackoverflow.com/questions/27999801
复制相似问题