Herd Software Development
DaVinci Graphics Library
In Windows color data is usually represented as a set of 3 BYTE values for red, green and blue color components, where (0,0,0) represents black and (255,255,255) represents white. Depending on the output device medium values like (128,128,128) are displayed differently, thus an area of (128,128,128) pixels might look brighter or darker than an area with alternating black and white pixels.
When using a cathode ray tube display the cause of this behavior is the non-linear brightness curve of the tube, while in the case of printing usually a black dot being printed is bigger than it ought to be, so the resulting picture looks ”darker” even though white is still white and black is correctly black.
This non-linear distortion is not correctable by the linear brightness and contrast parameters.
The most-known standard used to correct the non-linear brightness distortion is known as "gamma correction" according to the formula:
L' = L
L = not corrected color component value, standardized to values between 0.0..1.0
L'= corrected color component value, standardized to values between 0.0..1.0
gamma = correction value, for screens typically. 1.5-1.9
A simple technology to calibrate the display and / or printer with a good estimation for the gamma-correction value is to display a bitmap containing two fields: The first field with alternating white and black points (average brightness value = 50%) and a field with a consecutively gray bar (brightness value = 50%) If both fields are represented on the screen with same brightness, the display is calibrated correctly.
Such a picture is shipped with DaVinci with the file name GAMMA.BMP.
Since the "ideal" RGB coordinate system can’t be represented correctly on no output device, graphics are oftenly already published in a precompensated manner. A repeated gamma correction would display these graphics in a over compensated manner. Also precompensated graphics might be corrected with a correction value not matching the display of printer used.
Since the calculation of the power function is a slow function, Leonardo uses a two-step correction process. In the first step the application computes a BYTE-table of correction values using the function GammaCorrectionGetArray, while in the second step this array is used to modify the DIB with a call to GammaCorrectionApplyToDIB. The array can also be specified to the function DitherTo1 as a supplementary parameter.
Microsoft Windows NT can perform gamma-correction directly on the GDI-Level during display of a DIB on the screen with StretchDIBits and/or StretchDIBBlt. For this purpose, the HALFTONE mode must be is activated by a call of SetStretchBltMode in order to then adjust the gamma value with SetColorAdjustment. Activation of the HALFTONE-Mode is necessary for use of the gamma correction and affectes the display of 256- colors DIBs in a negative way, for they are dithered a second time. Unlike documentation, this technology is not supported from Windows 95 or Windows 98 since an error confirmed by Microsoft prevents this in Windows 95/98.
The following documents are in Adobe Acrobat .PDF format and require the Acrobat Reader software installed on your PC. Note that if Acrobat is installed as a browser plugin, you may need to manually save the .PDF file to disk when loaded, since the Acrobat plug-in may not automatically prompt you to save the document.