将图片复制到内部存储器存储器、图片

2023-09-06 22:26:58 作者:只会卖萌的乖辅助

我如何把一个映像复制到内存中并恢复之后呢?

How I copy a image to internal memory and recover after that?

推荐答案

您可以使用openFileOutput(以下组合)和Bitmap.com preSS()将图像存储到内部存储器。

You can use the following combination of openFileOutput() and Bitmap.compress() to store the image to the internal storage.

// Create a BitMap object of the image to be worked with
final Bitmap bm = BitmapFactory.decodeStream( ..some image.. );

// The openfileOutput() method creates a file on the phone/internal storage in the context of your application 
final FileOutputStream fos = openFileOutput("my_new_image.jpg", Context.MODE_PRIVATE);

// Use the compress method on the BitMap object to write image to the OutputStream
bm.compress(CompressFormat.JPEG, 90, fos);
 
精彩推荐