Colors are very important in application development on both displaying and editing/analyzing operations. All images (pictures, photos, drawings, icons, emojis, all UI elements โฆ) are consist of pixels in colors. You just need to change the colors of a pixel to draw a beautiful drawing or to edit a photo. You can set your drawings, bitmaps, images, you can create colorful BMP, JPG, PNG pictures, you can edit or analyze photos, you can analyze videos or camera buffer images in realtime operations. C++ Builder is very good and faster on these pixel operations in Colors. This feature is very important on dynamic operations to reduce time of analyze or edition. In this post we present how to use Colors in Modern C++.
TAlphaColorRec
TAlphaColorRecย provides access to the color channels record. You can get colors by these variables you can read or write each ARGB values in this variable. By changing Alpha parameter you can make your photos semi transparent by its value.
Some Examples to ARGB colors
0x00000000 Fully transparent black
0x88000000 Half transparent black
0xFF000000 Black
0xFFFFFFFF White
- If the highest-order byte is zero, then the low three bytes represent RGB color intensities for blue, green, and red, respectively. The valueย
$00FF0000
ย (Delphi) orย0x00FF0000
ย (C++) represents full-intensity, pure blue,ย$0000FF00
ย (Delphi) orย0x0000FF00
ย (C++) is pure green, andย$000000FF
ย (Delphi) orย0x000000FF
ย (C++) is pure red.ย$00000000
ย (Delphi) orย0x00000000
ย (C++) is black andย$00FFFFFF
ย (Delphi) orย0x00FFFFFF
ย (C++) is white. - If the highest-order byte isย
$FF
ย (theยSystemColor
ย constant), then the low three bytes represent Windows system colors likeยSysWindow
ย orยSysMenu
. These constants for system colors work only under Windows platforms.
http://docwiki.embarcadero.com/Libraries/Sydney/en/System.UITypes.TColor
TColorRec
Theย TColorRecย type defines useful constants identifying different types of colors forย TColor. Some of these constants map directly to the closest matching color in the system palette (for example, theย Blue
ย constant maps to the blue color). You can see the actual colors themselves in theย Colorsย table inย TColorRec.
Using Colors in Bitmaps
This example shows how to read pixel colors in ARGB format.
TColor
In C++ Builder TColorย is used to specify the color of a control. It is used by the Color property of many components and by a number of other properties that specify color values. Color is generally a property of components. You can specifyย TColorย as a specific 4-byte hexadecimal number instead of using the constants defined in theย TColorRecย type: