我是新的android,我想通過android編程在SD卡中保存GIF圖像。目前我已經從谷歌做了一些代碼來保存SD卡中的GIF圖像。但是當我將該圖像保存到SD卡時,它將顯示正常圖像而不是GIF圖像。如何在SD卡中保存GIF圖像?
這裏,這是我的代碼顯示GIF圖像
//Save code
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bitmap image = BitmapFactory.decodeResource(getResources(),
R.drawable.gpp3);
File outputFile = new File("/sdcard/gpp3.gif");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(outputFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
if (fos != null) {
AnimatedGifEncoder gifEncoder = new AnimatedGifEncoder();
gifEncoder.start(fos);
gifEncoder.addFrame(image);
gifEncoder.finish();
}
}
});
那麼,什麼是上述code.Please告訴我的問題。
https://github.com/madmaw/animatedgifencoder/ –
不要使用BitmapFactory可言。不要使用AnimatedGiffEncoder。假設你已經有了一個可繪製的gif圖像。所以把它複製到文件系統。 – greenapps
@greenapps當我用你的方式它會顯示.jpg擴展名和圖像是.gif –