我要在Android的图库中保存Gif图像。 我已经尝试了很多次将gif保存到图库中,但是当我按下保存按钮时,它已下载但不是gif格式。我不知道是什么问题。
请帮助我解决这个问题
public void saveImageToExternal(String imgName,Bitmap bm) throws IOException {
//Create Path to save Image
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES + "/savaimage1.gif"); //Creates app specific folder
path.mkdirs();
File imageFile = new File(path,imgName + ".gif");// Imagename.png
Log.e("msg",imageFile.toString());
FileOutputStream out = new FileOutputStream(imageFile);
Toast.makeText(this,"save",Toast.LENGTH_SHORT).show();
try {
bm.compress(Bitmap.CompressFormat.PNG,100,out); // Compress Image
out.flush();
out.close();
// Tell the media scanner about the new file so that it is
// immediately available to the user.
MediaScannerConnection.scanFile(Mainactivity.this,new String[]{imageFile.getabsolutePath()},null,new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path,Uri uri) {
Log.i("ExternalStorage","Scanned " + path + ":");
Log.i("ExternalStorage","-> uri=" + uri);
}
});
} catch (Exception e) {
throw new IOException();
}
}