I have an image that is to be displayed in about four different sizes depending on which activity the user is viewing. For instance a ListView will show one size, a GridView will show one size, a slide show will show one size, etc. If I use Picasso, will it download the image once or will it download one image for each size? Of course, I am taking into account that Picasso caches images (which is what I want). The key point here is that I have a single url for the image since it is one image.
Note that to keep the example simple, I mention one image. But of course I am talking about a set of images each of which needs to be manipulated as mentioned in the paragraph above.
If I use Picasso, will it download the image once or will it download
one image for each size?
Once for the original size as you get from the URL.
You can use the resize() method to resize the image and the original image would still stay at full resolution. I have done that in my app where I displayed a 600x600 image at 150x150 in a thumbnail and in full resolution later.
Related
I have a mobile app which has a screen with list of small images (3x3 grid). Click on image takes user to detail screen, where user can see that image in original size. Now, problem is that, for now, on backend side i only store full sized images (which i know is bad), but when i retrieve images for list i would like to return thumbs for original sized images.
The question is - what is the recommended thumbnail size to return?
Consider that this is an iOS and Android app.
Thanks in advance!
It depends how big you want to show it to the user.
i personally prefer 256X256
I have used both Picasso and Glide in order to load images asyncronously in grids with images coming from the phone's external memory and in order to download photos from the Internet.
But now for my Android game in the first screen I need to display an image below a title (the image takes up all available height). Then the user taps on a specific part of the image and the game starts.
The image content is a drawable resource.
So, for this specific use (a TextView and an ImageView below it which takes up all the remaining space), what should I do:
-Specify the image as ImageView's src property.
-Use an image loading library, such as Picasso or Glide
What do you suggest and why?
Thank you.
EDIT: The image would be static, a static drawable resource.
I am using the Glide library and wanted to know some more details about it.Does it load the entire picture into the memory,for example if i have a 1920x1080 picture and load it onto a phone with a screen size of 640x480 does it resize and compress or load the whole thing?
Also the thumbnail feature of glide,does it just load a icon version of the image so that it can be used for something like an avatar?
1) Depending on selected diskCacheStrategy Glide saves or original image (1920x1080 in your case) or image processed separately for each of your views (for example with .override(int width, int height) method). The only optimisation which Glide makes for you is storing of image in RGB_565 format instead of system default ARGB_8888.
If you are looking for strategy to reduce trafic as well as memory consumption here is description of model with downloading of images with custom sizes:
backend requirements
android client implementation
2) Thumbnail feature - it is just an option to fill the container view with reduced copy of original image insted of showing empty container or 'progress view' while downloading final image. Here is description of it's rule from Java doc thumbnail(float f):
* Loads a resource in an identical manner to this request except with the dimensions of the target multiplied
* by the given size multiplier. If the thumbnail load completes before the fullsize load, the thumbnail will
* be shown. If the thumbnail load completes afer the fullsize load, the thumbnail will not be shown.
So it is not the proper vay for avatar styling. The usual way instead is combination of override and centerCrop options.
Currently I'm working with an application where one activity holds a list view with image and text for each row. I'm downloading the images using the volley. When the list view item is clicked the app will switch to a another activity with a detail view where a large version of the clicked image will show. For the both time I'm using NetworkImageView.
Images are loaded in the list view with caching. But the problem appeared on the detailed view. The images are showing from the previously loaded cache with low resolution. I want to load a good resolution image on detailed view which will cache the image separately for large view.
For the both screen image url are same. How to do that ?
Thanks in advance.
First thing is a bit obvious - make sure you images are at the wanted quality.
If that's the case, you'll probably want to load the image "manually" using the ImageLoader class, as the NetworkImageView by default, optimizes the size of the Bitmap it creates to be the size of the view itself. So what happens is, you first load the thumbnail view which is small, and the saved Bitmap is created in that size instead of the original image size. Then, when the bigger view requests the same image, the cached version is returned which is a small Bitmap, and the view scales it up, creating the low-res appearance.
Try using ImageLoader.get() with the width and height appropriate to the bigger view in the detail screen.
The other alternative is to load 2 versions of the same image.
My scenario:
In my activity, I have to show 2 galleries, 1 with large image and another is a thumbnail(same exactly like default Gallery application).
My doubts:
I am planning to save as 2 images(1 with large size and another one with thumbnail size) in sdcard for fast processing. Is that good practice? since it will increase the size.
Or Shall I resize the large image during the getView method of BaseAdapter to small size for displaying in thumbnail gallery?
Which one is the good practice? I don't want to slow down my app.
See this example.
I will suggest you that, put only your large image inside your sdcard. But at runtime, Android provides a good facility to get Thumbnails using MediaStore.Images.Thumbnails.
Edit:
You can also get use Loading Sample Sized Bitmap. This will first create a sample size of your requirement. Then will give you a Thumbnail sized Bitmap.
StackOverflowAnswers:
1) Get thumbnail of image on SD card