Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing a gif image in android internal memory

Tags:

android

image

gif

I am quite new to android. I want to save image to internal memory and later retrieve the image from internal memory and load it to image view. I have successfully stored the image in internal memory using the following code :

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();
    }
}

This code is for saving the jpg image. If I want to save a gif image how can i do that?? Please help me. I can see the options for only jpg and png.

like image 384
Sanober Malik Avatar asked Feb 01 '13 07:02

Sanober Malik


1 Answers

Bitmap only works with png, jpg etc, and gif is a list of images, so you have to work with it as a binary file and use FileOutputStream and write(byte[])

like image 170
dilix Avatar answered Oct 17 '22 01:10

dilix