xbcg - Utility for setting brightness, contrast, and gamma in X

April 19. 2006 - Jukka Isohätälä

Here is a small piece of code that may prove useful to someone. This program allows you to set the brightness (black level), contrast, and gamma of the screen, independently for each colour channel on the X server side. Thus, this program should work for all graphics cards supporting the required X vidmode extensions (works for my Radeon 8500 perfectly).

NOTE. This program is still more or less in beta stage. If you experience problems, or wish to have more information about this program, drop me a line at jisohata at student dot oulu dot fi. Use this program at your own risk! There's no warranty of any kind, and the program can mess up your screen completely.

See the copyright notices / license in the source code for copying and modifying this software. (GPLv2 and XFree86 license notes)

Requirements

This program should compile and run on systems with functioning X11 installation, and (hardware supported?) XFree86 Vidmode extensions library libXxf86vm available. Latest X.Org versions should be OK. Graphics card support is not tested, but my Radeon 8500 works, at least. If the program works/doesn't work with your graphics card, please tell me.

Download

This is more or less experimental software, use at your own risk! Update. Installation now uses a usual configure, make, make install procedure.

Version 0.12 xbcg v. 0.12

Installation

Currently, only the source package is provided. Download the package, extract it with tar -xvjf xbcg-x.y.tar.bz2. Change to the build directory cd xbcg-x.y, run ./configure and then make, and if you want to, make install.

Usage

All the option names can be abbreviated as much as to keep them unique.

xbcg [-display display] [-screen screen] [-quiet] [-force] [-gamma f.f | -gamma r.r g.g b.b] [-brightness f.f | -brightness r.r g.g b.b] [-contrast f.f | -contrast r.r g.g b.b]

-display display
Specifies the server to connect to.

-screen screen
Allows you to select the screen to adjust.

-quiet
Stops xbcg from producing output to stdout.

-help
Prints out the usage.
-gamma f.f
-gamma r.r g.g b.b
Gamma correction. Can be given as a single value, which sets all channels to the given gamma, or separately for red, green, and blue channels. Can be abbreviated -g.
-brightness f.f
-brightness r.r g.g b.b
Brightness, i.e. the black level. Can be given as a single value, which sets all channels to the given brightness, or separately for red, green, and blue channels. Can be abbreviated -b.
-contrast f.f
-contrast r.r g.g b.b
Controls the contrast of the screen. Can be given as a single value, which sets all channels to the given contrast, or separately for red, green, and blue channels. Can be abbreviated -c.

On output, the program prints the chosen values, and warns about colour clipping or crushing.

The colour curve

The program loads a custom colour curve into X. The curve maps input pixel value xin, 0 ≤ x ≤ 1 , into output value xout via the formula

xout = b + c ⋅ xin1/g,

where b, c, and g are the given brightness, contrast, and gamma, respectively. I don't know if this is the standard formula, but at least I find it intuitive.

Motivation

For long I wasn't able to use Linux and X because of my poor monitor. Everything below graylevel of about 25% were crushed to black, making X completely useless when I wanted to edit photos, for example. Of course, I could have used xgamma to set gamma correction, but to get the darkest pixels visible, I'd have to use gamma of about 3, which meant that the brighter parts of the screen were completely washed out. The controls on the monitor itself, well, they are a real joke. If you have a monitor like mine, you know what I'm talking about.

I decided to remedy the situation. With some research into X vidmode extensions, I was able to find an easy way of loading a custom gamma ramp. This program only provides a simple user interface to those functions.

I hope this program helps someone!

Back to my personal pages