如何在将framelayout保存到图像时使用特定的位图宽度和高度?
答案 0 :(得分:0)
检查以下代码
public Bitmap convertFrameToBitmap(View view) {
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
return bitmap;
}
ry {
FileOutputStream output = new FileOutputStream(getActivity().getFilesDir() + File.separator+ image.png");
bitmap.compress(Bitmap.CompressFormat.PNG, 100, output);
output.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}