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.
Related
I'm implementing a RecyclerView with a grid layout where in each grid element there is an ImageView in which Glide should load an image taken from and API.
The API returns images of varying dimensions but mostly lage files, and gives the following information about each image:
width and height
size and format (jpg/png)
original size url
thumbnail size url
The thumbnail is way too low quality to be used.
It allows me to filter for under or above a specific resolution, but if I do that I end up missing on the most interesting images. I want to be able to download a compressed version of any image, can glide do that? Is there a workaround to speed up the loading of such big images?
I tought of allowing better quality of wifi networks but I would like to cover all cases. Thanks.
I have 3 URLs on gridview and only 2 of the 3 images load into the ImageView.
I am using Picaso:
Picasso.with(c).load(imageUrl).placeholder(R.drawable.progress_animation).fit().centerCrop().into(ivPicture);
I have also tried to skip caching:
Picasso.with(c).load(imageUrl).placeholder(R.drawable.progress_animation).fit().centerCrop().memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE).into(ivPicture);
Additional Info of image:
Width 2048 / Height 1371 pixels
File size = 224KB
File format is JPG
When I use Picasso's .resize(h w)to a lower the resolution eg: resize (100 100) for testing the image is downloaded but the aspect ration is not kept as some images will have a 9:6 ratio or vice versa 6:9 or a perfect square 5:5 and therefore I do not want to resize any images to a fixed ratio instead I use .fit().centerCrop() which works very well except for this 1 high-res image, Picasso just loads on the placeholder endlessly without any errors, I can understand if the pixels are too many but the file size is quite small in size I don't know why Picasso is struggling to download a +/- 200KB image.
Is there a way for Picasso to compress images over certain pixels perhaps?
Picasso can not process very big images because will receive out of memory .You must to do image transformation inside native code .Not in java
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 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.
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.