BCB analyzes red, green, and blue brightness from the Tcolor object

zhaozj2021-02-08  249

Analyze red, green, and blue brightness from the TColor object

Use the API function GtrValue, GetBValue, and getGValue. Here is an example in changing the color of the window background with an analysis of the red green blue. (Note: Before using the following example code, set the Color of the window to CLBLUE, ClNavy, or any other non-system color, such as CLBTNFACE.

Void __fastcall tform1 :: button1click (Tobject * Sender)

{

Byte nred = GtrValue (color);

Byte NBlue = getBValue (color);

Byte ngreen = getGvalue (color);

NRED = 10;

NBLUE - = 10;

Ngreen * = 1.05;

Color = (tcolor) RGB (NRED, NGREEN, NBLUE);

}

Note: The GET series function returns a luminance value of 0 to 255. Because the single brightness value is one byte so the return type is BYTE. When you set the brightness value of less than 0 or greater than 255, the RGB macro will intercept the extra bytes (it only takes only 8 digits).

Note: From a technical statement, these three GET functions are actually not a function, they are a macro of a C style. You can see their implementation in include / Win32 / Wingdi.h. One result of using the macro is: Function is not type safe. You can pass the char * to the macro without getting any warnings.

转载请注明原文地址:https://www.9cbs.com/read-1560.html

New Post(0)