After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 687650 - Generated gradients have banding
Generated gradients have banding
Status: RESOLVED WONTFIX
Product: gnome-desktop
Classification: Core
Component: Background
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Desktop Maintainers
Desktop Maintainers
: 553185 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-11-05 14:33 UTC by Øyvind Kolås (pippin)
Modified: 2015-04-21 17:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch implementing random dither for gradient renderer (3.66 KB, patch)
2012-11-05 14:34 UTC, Øyvind Kolås (pippin)
none Details | Review
patch implementing random dither for gradient renderer (4.62 KB, patch)
2012-11-05 22:44 UTC, Øyvind Kolås (pippin)
none Details | Review
patch implementing random dither for gradient renderer (4.61 KB, patch)
2012-11-05 22:52 UTC, Øyvind Kolås (pippin)
needs-work Details | Review
Screenshot of portion of horizontal gradient with/without patch applied (banding gets more apparent when the bands cover full height of screen) (51.83 KB, image/png)
2012-11-06 22:27 UTC, Øyvind Kolås (pippin)
  Details

Description Øyvind Kolås (pippin) 2012-11-05 14:33:13 UTC
8 bits per component (24bit/pixel) is not sufficient to avoid banding in gradients, in particular not for subtle gradients. Some form of dithering strategy needs to be employed to avoid such artifacts.

The simplest way of provoking such banding is to pick two of the darker neighbouring gray values in the color picker as gradient end points; the resulting wallpaper will be bands with abrupt transition rather than a smooth transition from one color to another.
Comment 1 Øyvind Kolås (pippin) 2012-11-05 14:34:32 UTC
Created attachment 228119 [details] [review]
patch implementing random dither for gradient renderer
Comment 2 Jakub Steiner 2012-11-05 18:56:03 UTC
Very much in favor of this. Wallpapers usually expose color banding a lot due to the fact the two color stop aren't very far in terms of contrast and are very far in terms of distance.
Comment 3 Øyvind Kolås (pippin) 2012-11-05 22:44:46 UTC
Created attachment 228197 [details] [review]
patch implementing random dither for gradient renderer

New patch, that avoids excessive per pixel function call overhead for the dither noise.
Comment 4 Øyvind Kolås (pippin) 2012-11-05 22:52:29 UTC
Created attachment 228199 [details] [review]
patch implementing random dither for gradient renderer

accidentally removed a newly introduced define when cherry-picking the commit to master - also slight fixup of coding style.
Comment 5 Øyvind Kolås (pippin) 2012-11-06 10:09:55 UTC
*** Bug 553185 has been marked as a duplicate of this bug. ***
Comment 6 Øyvind Kolås (pippin) 2012-11-06 22:27:45 UTC
Created attachment 228318 [details]
Screenshot of portion of horizontal gradient with/without patch applied (banding gets more apparent when the bands cover full height of screen)
Comment 7 Øyvind Kolås (pippin) 2012-11-10 15:31:33 UTC
Jimmac: in bug #676539 you ended up asking for the gradient selection ui code to be removed, with this patch landed; we could have some gradient presets as well. (personally I find a vertical grayscale going from dark grak in the top to black in the bottom to be a nice non-intrusive background once banding is gone).
Comment 8 Jakub Steiner 2012-11-11 14:42:00 UTC
I definitely don't want any new UI for defining custom gradients. What I want is some presets in the color section of the UI we should ship by default.
Comment 9 Bastien Nocera 2013-12-16 08:31:54 UTC
Review of attachment 228199 [details] [review]:

Patch doesn't apply cleanly anymore, though here's a review:
- add "gnome-bg: " to the commit subject
- More inline functions use
- More comments around the now non-obvious added code

::: libgnome-desktop/gnome-bg.c
@@ +2538,3 @@
 	int n_channels = 3;
 
+	/* to avoid the overhead of three function calls per pixel dithered,

Could you use inline functions to make this fast but more readable?

@@ +2567,3 @@
 			guchar *d;
 			d = dst + rowstride * i;
+			for (j = 0; j < width; j ++) {

Can you split this up into a separate (even inline) function?
Comment 10 Bastien Nocera 2015-04-21 15:48:19 UTC
Seeing as the patch provider won't ever update the patch because:
"the bug was never looked at by maintainers when the code was fresh; and I have created new and better methods since - you can have the bug as it is :]"
Comment 11 Øyvind Kolås (pippin) 2015-04-21 16:44:09 UTC
notes for people searching bugzilla for gradients and banding:

A better method for doing dithering of higher bitdepths to 8bits per component, that is currently the most likely method to be used when going from high bit depths to lower bitdepths exist at http://pippin.gimp.org/a_dither/ the examples on that page are all dithering from 24bit RGB to 8bit RGB for the GIFs, I've added another example at http://pippin.gimp.org/a_dither/gradients.html which contains dithering from floating point to 24bit RGB (8bits per component). The code on that page is live editable, if levels=255 is changed to levels=127; the results are not obviously worse - and there is sufficient entropy added that it would survive quantization causing global color management.

This is something that probably is desired for more than the background if one is using subtle gradients in a UI. The method can also be used on 8bpc RGB data rendered by cairo to reduce the additional banding caused if using 15bpp or 16bpp video modes.
Comment 12 Lapo Calamandrei 2015-04-21 16:51:03 UTC
So why aren't you implementing this around? :-)
Comment 13 Øyvind Kolås (pippin) 2015-04-21 17:02:27 UTC
If we could clone me or bug #171940 was resolved, this would be implemented in GIMP, GNOME and other software already. I neither run an up-to date GNOME desktop nor have a development environment configured for it, if someone else is implementing dithering code in GIMP, GTK+ or gnome-bg; there is running .js prototype code to look at on the referenced pages.