[TIMOB-24465] Android: ImageView quality (gradient banding)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-05-03T08:24:23.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.2.0 |
Components | n/a |
Labels | android, banding, imageview, quality |
Reporter | carlo |
Assignee | Gary Mathews |
Created | 2017-03-07T17:56:50.000+0000 |
Updated | 2017-09-01T08:41:08.000+0000 |
Description
ImagesViews in my app have poor quality, seems that a reduced palette is used.
This didn't happen when the same image is used as backgroundImage.
Open attached "banding_evidence.jpg" at full size on a contrasted screen.
var win = Ti.UI.createWindow({
backgroundImage:"/images/gradient.jpg"
});
win.add(Ti.UI.createImageView({
image:"/images/gradient.jpg"
}));
win.open();
Attachments
File | Date | Size |
---|---|---|
banding_evidence.jpg | 2017-03-08T09:42:02.000+0000 | 1454285 |
gradient.jpg | 2017-03-07T17:32:02.000+0000 | 24876 |
gradient.png | 2017-04-20T14:59:45.000+0000 | 32589 |
project.zip | 2017-03-08T12:41:20.000+0000 | 737778 |
Screenshot_20170307-181448.png | 2017-03-07T17:32:14.000+0000 | 316331 |
Hello, The issue is not valid. See the guide http://docs.appcelerator.com/platform/latest/#!/guide/Images_and_ImageView_APIs For background image By default, image will be scaled (stretched or squeezed) to fit the dimensions of the component. For Image view, since you have not define the height or width of the image view the the imageView will be the exact pixel size of the image you define.
It's not about size, it's about the quality. In the small image you can see circles of different colours instead of a gradient dithering as the background. With some kind of images this behaviour results in very ugly photos (attachment added).
Tried to disable hardware acceleration, no luck. Attachment updated. Please have a look.
My guess is that one of those defaults sets the wrong inPreferredConfig (Android use ARGB_8888 for the images): https://github.com/appcelerator/titanium_mobile/search?utf8=%E2%9C%93&q=inPreferredConfig https://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inPreferredConfig Maybe backgroundImage bring view his pixel format and this is why it works? Unfortunatly I can't spend more time on this, hope that this help to solve, because at the moment there's no way to put a gradient in a ImageView and display it correctly on Android and this is inexplicable for me...
We tried: https://github.com/caffeinalab/titanium_mobile/commit/c8020471229c00755dd73ce3a7b64852394c36f2 and in our custom build, no more "funny" gradients :)
master: https://github.com/appcelerator/titanium_mobile/pull/8978
Hi everyone, great that you found a solution for that! Is there a way to use this "opts.inPreferredConfig" without SDK 6.2.0.GA? I'm on 6.0.x now and would need a fix for a imageView. Thanks!
[~chmiiller] I think the best way would be to maybe try building the SDK locally with the required fix. You should be able to clone the repo, checkout the 6_0_X branch, then edit with the and build, the build produced will basically be identical to 6.0.4 with a version change plus your change. Check out [this](https://github.com/appcelerator/titanium_mobile#building-locally) for some more info on building locally, and I guess either
#core-contributions
or#helpme
on tislack for any help Changes verified in 6.2.0.v20170825165823 and 7.0.0.v20170825165854. Closing ticket.Great that this is fixed now! I'm using window.backgroundImage instead of a imageView and that has fixed my problem, but it is good that we can use ImageView now! Thank you so much