更新时间:2023-02-02 19:22:14
是的,你可以简单地把编辑的图像截图并创建可以在任何地方你想要保存一个位图
Yes you can simply take screenshot of the edited image and create a bitmap which can be saved anywhere you want
以下是用于获取位图功能
Below is the function for getting bitmap
public Bitmap getBitMap() {
try {
yourEditedPhotoCollageLayout.buildDrawingCache();
Bitmap bmp = Bitmap.createBitmap(yourEditedPhotoCollageLayout.getDrawingCache());
return bmp;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
和这种方式,您可以保存位图
and this way you can save that bitmap
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);
}
}