如何将ImageView的画布保存到位图?

时间:2012-10-27 07:39:51

标签: android android-canvas

我的ImageView

中有一个onDraw(canvas)

我试过了:

canvas.drawBitmap(...);//draw an extremely large background 3264 * 2448 pixels
canvas.drawLine(...);//draw target

我的问题是,如何将这个画布保存为png?谢谢!

2 个答案:

答案 0 :(得分:1)

从这里的问题: Drawing on Canvas and save image

imgView.setDrawingCacheEnabled(true);
Bitmap b = imgView.getDrawingCache();

FileOutputStream fos = null;
try {
    fos = new FileOutputStream(getFileName());
} catch (FileNotFoundException e) {
    e.printStackTrace();
}

b.compress(CompressFormat.PNG, 95, fos);

答案 1 :(得分:0)

您可以将视图缓存图像另存为png。