Contrast EnhancementContrast enhancement increases the total contrast of an image by making light colors lighter and dark colors darker at the same time. It does this by setting all color components below a specified lower bound to zero, and all color components above a specified upper bound to the maximum intensity (that is, 255). Color components between the upper and lower bounds are set to a linear ramp of values between 0 and 255. Because the upper bound must be greater than the lower bound, the lower bound must be between 0 and 254, and the upper bound must be between 1 and 255. The fg_contdcb() function applies a contrast enhancement transform to a direct color bitmap, so it can only be used when a high color or true color virtual buffer is active. The first fg_contdcb() parameter is the name of the array containing the direct color bitmap to be transformed, and the second parameter is the name of the array that will receive the transformed direct color bitmap (these two parameters can be the same array). The next two parameters are the lower and upper bounds, while the final fg_contdcb() parameter specifies the size of each bitmap in pixels. The code snippets shown here illustrate how we can apply a contrast enhancement transform, with bounds of 32 and 200, to an 80x50 true color bitmap:
C/C++:
Delphi:
Visual Basic:
The fg_contvb()fg_contvb
C/C++ and Delphi:
Visual Basic:
The fg_contrgb() function applies a contrast enhancement transform to a series of RGB color triples. Its first parameter is the name of the array containing the RGB color components, arranged as three-byte RGB triples. The next two parameters are the lower and upper bounds. The final fg_contrgb() parameter is the number of RGB triples to transform. The code snippets shown here illustrate how we can apply a contrast enhancement transform, with bounds of 32 and 200, to the non-system colors (colors 10 to 246) in the active logical palette:
C/C++:
Delphi:
Visual Basic:
If we're using a 256-color virtual buffer, the above sequences immediately change the colors of all pixels displayed in the application's client area if a palette-based display driver is active. If a high color or true color display driver is being used, the pixel colors will change the next time we blit the virtual buffer contents to the client area with fg_vbpaste() or fg_vbscale().
|
 
copyright 2001 Ted Gruber Software, Inc.