要在Android中从imageView保存图像

| 我在图像视图中有一个图像,我想将图像从图像视图保存到图库或任何存储空间,有人可以告诉我该怎么做吗??? 谢谢。 最好的祝福     
已邀请:
        简而言之,您可以从图形缓存中获取位图:
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
这里有几个问题,答案显示完整的代码: Android通过代码获取屏幕截图 如何在Android中以编程方式获取屏幕截图? 这些是View类的方法,因此它们适用于任何派生类(包括ImageView)     
        您可以在这段代码的背景中保存一个位图对象:
Matrix matrix = new Matrix();
matrix.postScale(scaledWidth, scaledHeight);

Bitmap resizedBitmap = Bitmap.createBitmap(originalBitmap, 0, 0,
    originalBitmap.width(), originalBitmap.height(), matrix, true); 
并在以后使用以下代码保存:
OutputStream fOut = null;
File file = new File(strDirectoy,imgname);
fOut = new FileOutputStream(file);

resizedBitmap.compress(Bitmap.CompressFormat.PNG, 0, fOut);
fOut.flush();
fOut.close();
    

要回复问题请先登录注册