C++Code SnippetLanguage FeatureLearn 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.

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:

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20Learn C++

What Is The Priority Queue (std::priority_queue) In Modern C++?

C++C++11C++14C++17C++20

What Is The Stack (std::stack) In Modern C++?

C++C++11C++14C++17C++20Learn C++

What Is The Queue (std::queue) In Modern C++?

C++C++11C++14C++17Learn C++SyntaxTemplates

What Are The Logical Operation Metafunctions In Modern C++?

Worth reading...
Quickly Learn How To Use Canvas Drawing In C++ On Windows