Android Glide Image Loading Library show blurred images - android

I know this question was asked already, but their answers didn't solve my problem.
I am using Glide in GridView
when GridView displays the pictures, it looks like this
I kept waiting but nothing changed. Then after scrolling the GridView, all the images suddenly appeared as shown below.
So, how to get better quality images without having to scroll? Is there any alternative solution for this problem?
I wrote my Glide code like this
Glide.with(activity)
.load(R.drawable.xyz)
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(R.drawable.img_hold)
.into(imgView);

found the problem. the image get blur or pixelated is because you doesn't set a fix width value in my imageview like this :
android:layout_width="wrap_content"
android:layout_height="100dp"
after i give it a fixed value like this:
android:layout_width="170dp"
android:layout_height="100dp"
all image is loaded nicely.
but I had tested on picasso lib, they load all image nicely although with android:layout_width="wrap_content"

Related

Firebase Images are not properly scaling up

I am working on an application which uses Google Firebase and RecyclerView. While retrieving the images from Firebease, images are not properly scaling up. When scrolling the recyclerview, sometimes images are showing as smaller ones and sometimes bigger. They are not scalling properly. I am using Glide to load the images. Please help me .
Also, is it a good idea to use Recuyclerview to use in complex application since OnbindViewHolder being called multiple times causing performance issues. Is there any alternative for that.
Please use this code:
Glide.with(profilePhotoImageView.getContext())
.load(profilePhotoUrl).centerCrop()
.transform(new CircleTransform(profilePhotoImageView.getContext()))
.override(40,40)
.into(profilePhotoImageView);
This means that you are setting a fixed width and height. In which profilePhotoUrl is the url of your image and profilePhotoImageView is the ImageView in which you want to display the image.
And don't forget to add the latest version of Glide in your build.gradle file.
'com.github.bumptech.glide:glide:4.0.0-RC1'
Hope it helps.

Pixelated images on Picasso, not sure of the cause

We are using Picasso for image handling on our app and we have been having problems with pixelated images. Unfortunately I have been unable to figure out why this is happening, whether by trying out different combinations of things on Picasso, or trying to find the answer online.
Here is our code for image handling currently (some parameter names changed to be easier to read):
Picasso.with(image.getContext())
.load(imageUrl)
.resize(100, 125)
.centerCrop()
.placeholder(R.drawable.image1)
.error(R.drawable.image2)
.transform(new RoundedTransformation(10, 4))
.into(image)
The RoundedTransformation function just gives the images rounded corners and the code for it is here (we did not write this code): https://gist.github.com/aprock/6213395
centerCrop is necessary to prevent the images from being stretched out when they are put into the ImageView.
Does anyone know why pixelation of images might be happening? Thanks and have a great day.

com.squareup.picasso returns empty (gray) image after resize

I have an imagepicker in my app and after I picked an image from an Intent.ACTION_PICK I wan´t to show it in a small thumbnail.
For image resizing and so on I use Picasso like this:
screenshot.post(() -> Picasso.with(this)
.load(Uri.parse(newState.attachmentUri))
.resize(screenshot.getWidth(), screenshot.getHeight())
.centerInside()
.into(screenshot));
Now I get Bugreports that this thumbnail remains empty (light gray). I couldn´t recreate the issue until I found an image in my gallery that creates the same issue.
I found out that this are images that where made with an effect called "focus effect" of the google camera. I cross-checked this by making several photos with this effect and several without. I can reproduce the error with the images with effect and the images without effect are working properly... What could be wrong here?
When I remove the resize all works fine..
Can you help me here?
Best regards
Artur
This happened for me when the ImageView had android:tint set to a value in the XML layout.
I guess that some parameters prevent the image from displaying correctly, which include the tint and maybe the resize parameters (according to the comments on your question).

loading image into android imageView with ion returns a blurry result

I'm trying to load an image from filesystem into an imageView with the ion library.
When I'm using the following code:
Ion.with(imageView)
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.load(uri);
it (sometimes) results in a kind of blurry image.
When not using ion like the following the pictures appear sharply:
imageView.setImageBitmap(BitmapFactory.decodeFile(uri.toString()));
Is there a standard compression coming with ion that I can disable?
Strangely not every picture is blurry when using ion, e.g. I have two identical images, only with another name. When I load them into the imageView with ion one is blurry, one is not.
Any help or tips are appreciated!
Ion tries to load the image to fit the bounds of the ImageView. So make sure your ImageView is sized properly in your layout. Alternatively, if you use adjustViewBounds=true to indicate the ImageView is adjusted by the image contents, it won't do that. Or alternatively smartsize(false).
Try this,
Ion.with(context)
.load(url)
.withBitmap()
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.intoImageView(imageView);

Why Picasso loads image faster if Placeholder is not used Android?

I used picasso as image library for my application. Images were loading a bit slowly so i decided to remove placeholder and it started loading faster.
How come if placeholder is not there its loading faster. But problem is if I remove placeholder. Before loading image it squeezes that area and once image loads it takes proper area filled with image.
My Imageview code below:
<com.wallie.imagview.SquareImageView
android:id="#+id/imageone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#drawable/border_image_view"
android:padding="1dp" />
Picasso code i used earlier (loads image a bit slower ):
Picasso.with(context).load(url)
.placeholder(R.drawable.image_loading)
.into(imageView);
Picasso code i used now (loads image faster):
Picasso.with(context).load(url)
.into(imageView);
But problem is it squeezes space for image without placeholder and my spinner for all images get in one place.

Categories

Resources