Load only some images from disk cache using Universal Image Loader - java

I am using the Universal Image Loader disk cache feature. I have restricted it to only cache images with the a maximum of 480x320 resolution. This works nicely, but when I tap those images to open the full size images, UIL loads the image from the disk cache and I see a stretched / distorted version of the small cached image.
I want to know how to tell UIL to load the images from disk cache but only for specific images. I have tried searching without luck.
Thanks.

It seems that the only answer to this is to create two instances of the ImageLoader. One with disk caching and one without it.

Related

Multi-Resolution in Android?

I have been going through to achieve Multi-Resolution in android built in eclipse.
I have this app where i have used a lot of images, firstly the only limitation i have is size, i cannot exceed 5MB size for the app, surprisingly i was able to do this by just storing only in the xxhdpi folder, not all of the dpi folders, such as ldpi, mdpi and above xxhdpi devices dont support the app.
As you can see if i store all the folders with the respective images, it makes the app of size almost 15MB. I have read in forums that in cocos2dx there is a function to which only image is provided, which automatically scales the image with the device, and returns it to be set respectively,
i was wondering if there is a way to do this in android as well, thanx in advance
You'd better use SVG (vectorial images) files, through a 3rd party library.
SVGs are scalable (up or down, doesn't really matter) without loosing definition, due to their vectorial nature (it's just an xml file with geometrical definitions and color transitions).
This way, you'd have only 1 version of the graphical file and then only get the desired bitmap from it, with no ugly pixellation.
The most used libraries so far are android-svg and svg-android, primarily (there are a few other ones, and some variants to the proposed ones too).
Scaling is what they are meant to: you provide the SVG file (possibly in your raw or assets folder) and the needed dimensions (in pixels).
And get your bitmapped image out of the vectors.
Fantastic.
Our user Paul LeBeau is the author of AndroidSVG and he always lends a friendly support to whom needs a hand with his library.

What is the standard way of compressing uploaded images on web applications?

I have an application where users can upload images.
This images are usually taken directly from cameras and in 1mb sizes or more.
May I know what is the standard way of compressing this images before saving them to database as BLOB?
The images stored in database are just for viewing, there is no requirement to edit the image.
I have read this:
Compress Image before Saving to disk in Java
But I am wondering there are more standard ways so that the system can be more maintainable.
some codes and links will be greatly appreciated +1

Which is Faster regarding Android Images IO

Which is faster, to recieve images as JPG from server, and save it, then show it in a ListView or what ever
OR
receive images in an XML (as encoded String) from server, then decode it, then show it in a ListView (or even save it then show it from memory)
what is the best way (regarding performance) in transfering images FROM a server TO an android device
thanks in advance
That depends on where the limitation is. If the bandwidth of your connection is very small try to transfer as few bytes as possible. However, high compression usually costs more CPU, so if CPU power is limiting you it may be better to use a lower compression.
I am not sure what you mean by "receive images in an XML". Is it some vector format like SVG? That would normally be much smaller than a raster image (especially for large sizes).
To sum up, you will need to do some experiments to find out what works best in your case.
The best way is to get the image URL from the server and then download the image using some image managing library like https://github.com/nostra13/Android-Universal-Image-Loader or google's volley. These kind of libraries highly configurable and taking care of all the aspects of managing a bitmap.

store bitmaps in an array?

Hi I am trying to download some images from the server, and I won't save them to the SD card because I want them to be gone when the application finishes. Therefore I want to store them in an array of bitmaps. Is this feasible? My largest image would be about 1000X1086 and there would be about 30-40 of them.
No. A bitmap is stored in memory as uncompressed bytes. A 1000x1086 full color bitmap is about 4MB. Most phones allow an app to use 16-40 MB max, and that includes built in resources. You're over by a factor of 10.
I'm using Universal Image Loader. You can save the images only in memory and clear it when you exit.
Here are all options for download images.
https://github.com/nostra13/Android-Universal-Image-Loader
You have an option... which ain't built in phone memory dependent...
You can save the images in the memory card and delete when the app finishes itself...
This is a really elegant method...

How can I download scaled down version of an image?

I need to download images that are very large 5mb+.
I am aware of scaling the image before displaying it to save phone memory but the problem of downloading a large image still remains.
How can I download, say, a 50% scaled down version of an image rather than downloading a full image then scaling it?
It must be supported by the server from which you download.
If the server is not yours, you need to look up that server's documentation (or reverse-engineer).
If the server is yours, it depends on the used technology. Look up an image manipulation library for that particular server-side technology you are using.
in case of imgur.com,
look here: http://api.imgur.com/
Imgur lets you make 500 calls per hour per IP, or 1000 if you are registered. Uploads count tenfold.
The metadata about an image is documented here: http://api.imgur.com/resources_anon#image_hash . Access either api.imgur.com/2/image/[hash].xml or api.imgur.com/2/image/[hash].json, and pick either image.links.small_square (90x90) or image.links.large_thumbnail (?x640) from the response. Note that imgur also generates thumbnails (160x160) for its home page. URLs for these seem to be i.imgur.com/[hash]b.jpg
The link to the large image is i.imgur.com/[hash].jpg, so if your link is http://i.imgur.com/xDpEF.jpg or http://imgur.com/xDpEF, then xDpEF is the hash you need.
It is NOT possible to download a scaled down version of some image when the web server does not provide a scaled down version.
You'll need to scale them in the web/on the server, where you host them. So the question is not java/android, but on the webserver, and depends on it.
You can't, unless your server supports scaling down the image before you download it. If the server doesn't have that option, your best option is to scale it down while you read the image from the stream, using BitmapFactory.Options inSampleSize.
Sir it is impossible because if you are downloading it from any server then server must have the scaled image in many forms like 50% scale or 25% scaled. So it is possible only when the server is maintained by you from where you are downloading the image and at backend you have provided some method to scale the image.
If you are downloading the image from any server then is is not possible to get scaled image from server without any backend procedure to scale image.
You will need to download the image to a file, then use BitmapFactory with BitmapFactory.Options to determine the size of the image. From the image size, calculate how much you want to scale it, and again use BitmapFactory (with Options) to load a scaled version of the image.
It depends on Server, Server should support scaling down the image.
In addition to the other answers there is one solution that may work without special software on server side;
If the images are stored on the server in JPEG format and uses the interlaced / progressive mode you would be able to download them partially for creating a thumb nail.
This special mode was designed to see a preview-image while it is still downloading. Compacting the preview image could result in an image that can be used as a thumbnail.
However I don't know a library that would support thumbnail loading this way.

Categories

Resources