I would like to download a animated GIF file (more specifically, a weather radar loop), decompile it in frames and play the contents via AnimationDrawable.
The latter part and downloading the image is not a problem, but the middle part is puzzling me: how on earth can I extract the separate frames from the GIF within an app?
I found an easy to use GifDecoder that did the trick for me.
Related
I am making an app that generates GIF from images taken on camera.
I have used two libraries to generate GIF, this one and this one, but both generate GIF with awful quality. Image is posterized.
For example, here is the original image:
and here is the image generated by Gifflen library:
There are some apps on Google Store that generate GIF and don't destroy image quality. Is there a way to increase GIF quality (generation time increase is ok) or is there another library that can generate GIF?
EDIT
Like Wildopper said in the comment, it is probably dithering of the image that is causing the problem. Here is the explanation on Wikipedia, but I don't know how to implement it.
I have this interesting problem. I need to convert animated SVG or just plain SVG to a video format either on the client side (iOS/Android) or on the server side (.NET).
There does not seems to be a way to accomplish it.
My initial approach was to animate SVG using Core Animation (on iOS) and convert that to a video, but a similar solution does not exist in the Android world.
My next approach was to use FFMPEG, but that too fell short. then I shifted my focus to .NET, but that too, nothing came out of it.
I'm looking for some general direction. Can it be done?
The idea is to take multiple SVGs and convert them to a video file along with some audio.
Thanks in advance!
I am using the android-gif-drawable library to display an animated gif in an Android view. This library can load a file from an input stream, byte array, byte buffer, or from a locally stored file. I am looking for a way to use Picasso to download the gif and pass it to the library to load into the GifImageView. Unfortunately, once the downloaded image is converted to a Bitmap, it just becomes a single frame. I'm thinking a custom request handler might be able to hand off an input stream for the GifImageView to load, but I cannot seem to figure out the syntax to do this. Does anyone have pointers or thoughts on doing this?
If you haven't figured it out yet, you can use the library Ion. I was facing the same problem a few days ago, and it worked for me.
As far as I know, swf's and gif's inside WebViews are not officially supported by Android, eventhough they work in my HTC Desire Device.
I'm building an app that it's all based in a WebView. What i did is code the 'app' as HTML, put it into the 'raw' folder and once the app starts, it puts all the htmls and images into a folder on the SD (if they're not there yet).
Now I need display some animations in there. I made them with Actionscript and I was glad that it seemed to work (Animations were 25KB each), but after a while publishing it, i got reports from people that coulnd't see the animation.
Then I patched them into a GIF (raised memory to 400KB-1MB each). At this point, I decided to take the gifs out of the raw folder, and download them from one server in the web the first time the app runs, so my apk doesn't get too big. But I get complaints again that people can't see it (then I found that GIF is also unsupported)
Google-ing and stackoverflow-ing I found that the only solution is to split those GIFs into separate images and show them with javascript one by one to create the animation. I guess this method is OK for small animations (like some face saying hello or something like that), but for whole animations.... It weights about 3MB per animation (when the swf was 25KB...). And I think taking 30MB (possibly more in the future for new animations) from user's data quota is not nice.
So:
Is there any other solution?
Are there lots and lots of phones that don't support SWF? and GIF? If they're not too many, I would consider putting on my app's description that the animations won't work if the phone has low memory (animations are not very important into my app)
Thank you very much,
VĂctor
edit: Additional information: Animations are like this one.
So... I found the only way was to use HTML5 canvas animation, since surprisingly it is supported by many devices.
The animation is not as smooth as in a GIF-compatible device, but I rather make it accessible for everyone.
So, CommonsWare answered my 2nd question, but I will answer my 1st one: Yes, use HTML5. It didn't take a huge work, since JS can be Object-Oriented as well, and syntax is fairly similar to AS3.
And the best part is that the base code only weights 34KB (let's say the engine plus all the images), and each animation (in a separate file) weights between 1 and 2KB. That was awesome, I can put them all into my Android's raw folder.
Thank you very much CommonsWare for your comment.
How to generate gif frame by frame, base on a canvas?
I'm writing a chess game, and want to generate a gif file from every move by user. Is there any apis provided by sdk?
Thanks.
Unfortunately that is not possible with any built-in function. The SDK does not come with the ImageIO class. You can make use of this animated GIF encoder:
http://www.java2s.com/Code/Java/2D-Graphics-GUI/AnimatedGifEncoder.htm