Picasso load image into GifImageView (android-gif-drawable library) - android

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.

Related

Picasso not loading JPG format

I'm getting some images from api and showing them via picasso library. Unfortunately it isn't showing .JPG formatted images while it perfectly works with jpg images. Is there anyone who had such problem? Is there any cure or we can't use picasso with JPG?
If I remember well, I had the same problem in general with android studio, so this doesn't regard strictly Picasso library. What I know is that in a case (.jpg) those files are recognized as multimedia files (so treated that way) in the opposite case (.JPG) they are considered as files and treated more generally.
Usually I convert all .PNG into .png and all .JPG into .jpg.
Hope it can help you!

converting video file byte[],or Buffer into bitmaps of Android,getting images from videofile

I am trying to represent images from that video file in Android controls.
I loaded video file in byte[] , also in other types like Buffer , ByteBuffer and Bitmap,I used all the functions available in Bitmap and Bitmap factory class but unable to get the images to be represented in android image button.
Can any one tell the Idea of getting images from above mentioned data types .
Any other study which you can recommend is welcome.
I get it worked , I recommend all the readers to use FFMPEG using ndk and get all the frames the require . lot of sample projects there on git

Decompiling animated GIF file within an app

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.

Memory efficient way to scale an image

I've got an app where the main viewing area is a WebView.
It's a service where a user can also upload a photo. However, with the WebView, and photo uploads, I'm getting some OutOfMemoryErrors.
Usually all it takes is a page loaded in the WebView, and then simply trying to open an image with something like this:
Bitmap bmp = BitmapFactory.decodeFile(path);
The only reason I need to open the file at all is so that I can scale it down so that it fits in a max width/max height dimensions before uploading it.
I've even tried opening it in a sampled fashion, similar to what's mentioned here:
Strange out of memory issue while loading an image to a Bitmap object
However, with a complex webpage loaded in the WebView, I still get OutOfMemoryError when trying to open the image.
Is there a way to scale it, maybe using another process or something, that's more memory efficient?
I'm glad you asked, I was about to investigate this for my own project.
It looks like BitmapFactory.Options is your friend here, specifically BitmapFactory.Options.inSampleSize enter link description here. You can use BitmapFactory.decodeStream to get the image dimensions without creating a Bitmap.
Googling revealed the com.bristle.javalib.awt ImgUtil classes; these appear to be open source (don't know the license), and are AWT based, so may work on Android. The interesting method is ImgUtil.scalueImageToOutputStreamAsJPEG, which works with InputSteam/OutputStream, so may be memory efficient.
UPDATE
An alternative is to write a JNI wrapper around /system/lib/libjpeg.so, which appears to be standard on Android devices. This library works with scanlines, so can be memory friendly. Another plus is that using JNI should be faster than pure java.
Hope this helps,
Phil Lello
I had a similar problem and found a workable solution using BitmapFactory.Option.inScale. You can find details here: How do I scale a streaming bitmap in-place without reading the whole image first?

Display image using a RSS feed

I have an application in which use a RSS feed reader. My problem is that I don't know what is the best way to display an image. The closer I could get was to pull the image description (). I know I could parse this String by myself and get the image url, but I was wondering if there is a more elegant way to solve this issue. I tried using the SAX and the DOM classes, but I couldn't figure it out.
Best way to DISPLAY the image? I'm not sure if that's actually what you're asking, but just use an ImageView. Use an AsyncTask to download the image in the background, and then create a new Drawable from that downloaded image (might even want to cache it to storage) and set that as the source for the ImageView.
there is a library for downloading and caching images in background from the URL
https://github.com/koush/UrlImageViewHelperSample
=)
Are you asking how to get the image URL from the XML RSS feed? There's nothing built into the SDK that's going to help you parse the XML, other than SAX or DOM which you have already noted. There is a learning curve to those, but they are reasonable approaches.
There's a project called ROME that is an API for robustly parsing all sorts of feeds, including RSS. You could import this library into your android app. Note that this library has other dependencies, so you'd have to import them also. I haven't done it personally, but I have heard of people using ROME in Android apps, so it's doable.
Or more simply, if you just want the image URL and you don't need a complete feed parser, you can use java.util.regex to parse out the fields you want.
If you are asking how to display the image after you have the URL, kcoppock's answer explains it.

Categories

Resources