Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24465] Android: ImageView quality (gradient banding)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-05-03T08:24:23.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.2.0
Componentsn/a
Labelsandroid, banding, imageview, quality
Reportercarlo
AssigneeGary Mathews
Created2017-03-07T17:56:50.000+0000
Updated2017-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

FileDateSize
banding_evidence.jpg2017-03-08T09:42:02.000+00001454285
gradient.jpg2017-03-07T17:32:02.000+000024876
gradient.png2017-04-20T14:59:45.000+000032589
project.zip2017-03-08T12:41:20.000+0000737778
Screenshot_20170307-181448.png2017-03-07T17:32:14.000+0000316331

Comments

  1. Sharif AbuDarda 2017-03-07

    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.
  2. carlo 2017-03-07

    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).
  3. carlo 2017-03-08

    Tried to disable hardware acceleration, no luck. Attachment updated. Please have a look.
  4. carlo 2017-03-08

    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...
  5. Flavio De Stefano 2017-04-05

    We tried: https://github.com/caffeinalab/titanium_mobile/commit/c8020471229c00755dd73ce3a7b64852394c36f2 and in our custom build, no more "funny" gradients :)
  6. Gary Mathews 2017-04-20

    master: https://github.com/appcelerator/titanium_mobile/pull/8978
  7. Carlos Henrique Zinato 2017-08-04

    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!
  8. Ewan Harris 2017-08-28

    [~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.
  9. Carlos Henrique Zinato 2017-09-01

    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

JSON Source