So I have no clue why this is happening. I am using Universal Image Loader to load these images. It seems like the last line of pixels is being streched for some weird reason. I want the image to just stretch out evenly. (I don't care that it will look weird. The images below are for demo purposes.)

Also, don't mind the first and last image. I purposely blurred that out because it had someone's face on it.

Images appear like this This is how I set up my Universal Image Loader:

    //setup Image Loader for loading cruise line logos
    displayImageOptions = new DisplayImageOptions.Builder()
    .showImageOnLoading(R.drawable.ic_launcher)//show this image when image is loading
    .showImageForEmptyUri(R.drawable.ic_launcher)//show this image incase image doesn't exist
    .showImageOnFail(R.drawable.ic_launcher)//show this image if fetching image from URL didn't work
    .cacheInMemory(true)//cache image in RAM
    .cacheOnDisc(true)//cache image in device for later use
    .considerExifParams(true)
    .displayer(new RoundedBitmapDisplayer(5))//super subtle rounded corners on images
    .build();
有帮助吗?

解决方案

This is caused by the way RoundedBitmapDisplayer draws the bitmap.

If you look at the source, you'll see that it uses a RoundedDrawable, which uses canvas.drawRoundRect() to draw a rounded rectangle of the desired size of the Drawable, using the downloaded image as the texture via a BitmapShader. BitmapShader does not support scaling (only clamping and tile modes). Try using a SimpleBitmapDisplayer instead which uses the normal ImageView.setImageBitmap() way of displaying the image.

If you need rounded corners, you'll have to find a different way to implement that, for example by scaling the Bitmap to the desired size first. Another option is to call Canvas.saveLayer() before delegating to BitmapDrawable for the scaling, and then applying the rounded corner masking effect using PorterDuff.Mode.DST_IN. Either way you'll end up writing a bit more low-level code, but you should be able to encapsulate everything nicely in a custom BitmapDisplayer.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top