我是 android 的新手。我想将图像保存到内部存储器中,稍后从内部存储器中检索图像并将其加载到 ImageView 中。我已经使用以下代码成功地将图像存储在内部存储器中:
void saveImage() {
String fileName="img"+ cnt +".jpg";
//File file=new File(fileName);
try
{
FileOutputStream fOut=openFileOutput(fileName, MODE_PRIVATE);
bmImg.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
}
catch (Exception e)
{
e.printStackTrace();
}
}
此代码用于保存 jpg 图像。如果我想保存 gif 图像,我该怎么做?请帮我。我只能看到 jpg 和 png 的选项。
最佳答案
位图仅适用于 png、jpg 等,而 gif 是图像列表,因此您必须将其作为二进制文件使用并使用 FileOutputStream和 write(byte[])
关于android - 将 gif 图像存储在 android 内存中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14641545/