I wont to make simple image to Animated image like GIF.I can select the image for gallery and store in image file.But, How i can modify image file to animated image or GIF File .
Asked
Active
Viewed 1,213 times
1
-
use gif Encoder to merge images and create animation – Divyesh Patel May 03 '17 at 10:54
-
but how it possible? – Idrish Multani May 03 '17 at 10:57
-
can you give me a any code in ans? – Idrish Multani May 03 '17 at 10:57
2 Answers
3
you have to select images you want to make GIF, then use bitmaps and run code in background Thread/Asynchtask:
Here i used Drawable, in your case convert images into bitmap and use it.
Bitmap one=BitmapFactory.decodeResource(getResources(),R.drawable.neon0);
Bitmap two=BitmapFactory.decodeResource(getResources(),R.drawable.neon1);
Bitmap three=BitmapFactory.decodeResource(getResources(),R.drawable.neon2);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
AnimatedGifEncoder encoder = new AnimatedGifEncoder();
encoder.start(bos);
encoder.addFrame(one);
encoder.addFrame(two);
encoder.addFrame(three);
encoder.finish();
FileOutputStream outStream;
try{
outStream = new FileOutputStream(Environment.getExternalStorageDirectory().getPath() +
"/IMAGES_GIF/" + "animated.gif");
outStream.write(bos.toByteArray());
outStream.close();
}catch(Exception e){
e.printStackTrace();
}
Get Class from:

Divyesh Patel
- 2,576
- 2
- 15
- 30
-
thanks. ,but i want only one image to convert in Gif like animation not using multiple images. can you give me a some guiedence for the wave animation – Idrish Multani May 03 '17 at 11:19
-
-
i want only 1 image to convert GIf and set in animation.it possible? – Idrish Multani May 04 '17 at 03:46
-
you can not create animation from single image.For that you need to use Some software to animate part from single image merge that parts in GIF file. – Divyesh Patel May 04 '17 at 05:13
-
-
means wave animation and above it single image with transparency? – Divyesh Patel May 04 '17 at 07:58
-
give direct animation on image like wave. or set make gif like wave animation using single image. – Idrish Multani May 04 '17 at 12:10
-
http://www.netanimations.net/Water-waterfalls-lake-stream-ocean-animated-gifs.htm – Idrish Multani May 04 '17 at 12:15
-
i have no idea how to create that animation using single image. above link shows gifs that uses multiple images – Divyesh Patel May 04 '17 at 12:18
1
This question needs a lot more information. Is the file already a GIF and it is not animating or are you trying to convert an image to a GIF? The latter is not possible, a GIF is a series of images.
You must create the GIF elsewhere and it is easiest to use a library like Glide (https://github.com/bumptech/glide) or Picasso (http://square.github.io/picasso/) to load the GIF.

ShibbySham
- 71
- 1
- 2
- 5