Site icon Learn C++

Colors In Modern C++ For Windows Development

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.

[crayon-6623a143a3f05039824436/]

Some Examples to ARGB colors
0x00000000 Fully transparent black
0x88000000 Half transparent black
0xFF000000 Black
0xFFFFFFFF White

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.

[crayon-6623a143a3f0c723000049/]

Using Colors in Bitmaps

This example shows how to read pixel colors in ARGB format.

[crayon-6623a143a3f10953563958/]

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:

[crayon-6623a143a3f12071277908/]

Exit mobile version