3

I've been researching this for quite awhile now. I have 2 Samsung phones, one is S4 and one is Samsung Win. The image on my S4 looks like this:

enter image description here

Whereas the image looked like this if I view this normally on an image viewer:

enter image description here

In fact this is how it needs to look like. It looks like this on my Samsung Win but not on S4.

Originally the size of the image is 700x256 and then upscale it to 1280x455 for Samsung S4 and still no effect. It looks the same. I am not quite sure anymore if this is gradient banding or scaling problems. I've read several post and blogs and did some solution like putting these images on /raw folder and setting:

@Override
public void onAttachedToWindow()
{
    super.onAttachedToWindow();
    getWindow().setFormat(PixelFormat.RGBA_8888);
}

And to no effect. Still the same blotchy pixels on my image.

I've read these following post:

Android: Using linear gradient as background looks banded

http://www.curious-creature.com/2010/12/08/bitmap-quality-banding-and-dithering/

http://android.nakatome.net/2010/04/bitmap-basics.html

The nature of my work requires a little bit of confidentiality so I cropped the image shown here. What I am actually doing is a comic similar to Webtoon app. Unfortunately no matter what I did, the app looks horrible on S4 as the pixels are blotchy. I am using Glide to load the images and tried this, still the same thing. I haven't tried any other phones other than S4 and Samsung Win. I give up, I need help.

Any help would be greatly appreciated!

Community
  • 1
  • 1
Neon Warge
  • 1,817
  • 6
  • 29
  • 53

1 Answers1

0

There are numerous reasons for using Glide outside of just using the built-in features that Android provides for you out of the box, such as memory management and pinch zoom on the view to name a couple.

There are a couple different approaches and components that can lead to banding and artifacts when using the Glide library that I have found.

When using the load protocol for the library below

SimpleTarget target  = new SimpleTarget<BitmapDrawable>() {
        @Override
        public void onResourceReady(@NonNull BitmapDrawable bitmapDrawable, @Nullable Transition<? super BitmapDrawable> transition) {
            bitmapDrawable.setDither(true);
            bitmapDrawable.setAntiAlias(true);
            pViewHolder.updateBitmap(bitmapDrawable.getBitmap());
        }
    };

    mGlideRequest.clone().format(DecodeFormat.PREFER_ARGB_8888).signature(signature).diskCacheStrategy(DiskCacheStrategy.DATA).load(current.mUri).into(target);

The one that made the most difference for me in improving quality and removing bands that I saw on gradients was .diskCacheStrategy(DiskCacheStrategy.DATA) which forces the library to download and store the original image for referencing and loading later.

It can be also be seen that the format is forced into the DecodeFormat.PREFER_ARGB_8888. This is due to the fact that Android could be handling resources with 565 instead of 888 RGB representations. For that reason, it is requested that we also add this to our window in our Activity:

@Override
public void onAttachedToWindow() {
    super.onAttachedToWindow();
    Window window = getWindow();
    window.setFormat(PixelFormat.RGBA_8888);
}

These are a series of updates that I would be sure to implement in order to remove banding and bad quality imagery.

Jay Snayder
  • 4,298
  • 4
  • 27
  • 53