Sign in Join
Wiki copytemporary

BGRABitmap Color definitions: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-List of color definitions and string conversion functions in [[BGRABitmap]] library. They are provided by [BGRABitmapTypes unit](<https://bgrabitmap.github.io/doc/BGRABitmapTypes.html>).
1+List of color definitions and string conversion functions in [[BGRABitmap]] library. They are provided by [BGRABitmapTypes unit](https://bgrabitmap.github.io/doc/BGRABitmapTypes.html).
22
33### Color definitions
44
5-_BGRAPixelTransparent_ : TBGRAPixel;
6----
7-| This is the value used for transparent pixels. In theory, any color with alpha = 0 is transparent, however it is recommended to use all other channels to zero as well.
8-_BGRAWhite_ : TBGRAPixel;
9-| White opaque
10-_BGRABlack_ : TBGRAPixel;
11-| Black opaque
12-_clBlackOpaque_ = TColor($010000);
13-| This color looks just like black. It is needed for drawing black shapes using the _Canvas_ property of TBGRABitmap. This is a standard TCanvas and when drawing with pure black (_clBlack_), there is no way to know if something has been drawn or if it is transparent
14-_TBGRAColorList_ = **class**
15-| Contains a fixed list of colors
16-| **constructor** Create;
17-| | Creates an empty color list
18-| **procedure** Add(Name: **string** ; **const** Color: TBGRAPixel); **overload** ;
19-| | Add a color to the list
20-| **procedure** Finished;
21-| | Ends the color list and prevents further modifications
22-| **function** IndexOf(Name: **string**): integer;
23-| | Returns the index of a color with a given name
24-| **function** IndexOfColor(**const** AColor: TBGRAPixel; AMaxDiff: Word = 0): integer;
25-| | Returns the index of a color. Colors are considered to match if the difference is less than or equal to _AMaxDiff_
26-| **property** ByName[Name: **string**]: TBGRAPixel **read** GetByName;
27-| | Gets the color associated with a color name
28-| **property** ByIndex[Index: integer]: TBGRAPixel **read** GetByIndex; **default** ;
29-| | Gets the color at the specified index
30-| **property** Name[Index: integer]: **string** **read** GetName;
31-| | Gets the name of the color at the specified index
32-| **property** Count: integer **read** FNbColors;
33-| | Gets the number of colors
34-_VGAColors_ : TBGRAColorList;
35-| List of VGA colors: Black, Gray, Silver, White, Maroon, Red, Purple, Fuchsia, Green, Lime, Olive, Yellow, Navy, Blue, Teal, Aqua. Shortcut constants are provided: _VGABlack_ , _VGAGray_...
36-_CSSColors_ : TBGRAColorList;
37-| List of [web colors](<https://www.w3schools.com/cssref/css_colors.asp>). Shortcut constants are provided: _CSSBlack_ , _CSSRed_...
38-**function** BGRAToStr(c: TBGRAPixel; AColorList: TBGRAColorList = **nil** ;
39-| Converts a TBGRAPixel value into a string, using color names provided in _AColorList_ , and considering that a color matches in the color list if its difference is within _AMaxDiff_
40-**function** StrToBGRA(str: **string**): TBGRAPixel; **overload** ;
41-| Converts a fully defined string into a TBGRAPixel value. Color names from _VGAColors_ and _CSSColors_ are used if there is an exact match
42-**function** StrToBGRA(str: **string** ; **const** DefaultColor: TBGRAPixel): TBGRAPixel; **overload** ;
43-| Converts a string into a TBGRAPixel value. If the value is not fully defined or that there is an error, _DefaultColor_ is returned. Color names from _VGAColors_ and _CSSColors_ are used if there is an exact match.
44-**function** PartialStrToBGRA(str: **string** ; **const** fallbackValues: TBGRAPixel; **out** error: boolean): TBGRAPixel;
45-| Converts a string into a TBGRAPixel value. If the value is not fully defined, missing channels (expressed with '?') are filled with fallbackValues. You can check if there was an error with the provided boolean. Color names from _VGAColors_ and _CSSColors_ are used if there is an exact match.
46-**procedure** TryStrToBGRA(str: **string** ; **var** parsedValue: TBGRAPixel; **out** missingValues: boolean; **out** error: boolean);
47-| Converts a string into a TBGRAPixel value into _parsedValue_. _parsedValue_ is not changed if some channels are missing (expressed with '?'). You can check if there was an error with the provided boolean. Color names from _VGAColors_ and _CSSColors_ are used if there is an exact match.
48-
5+*BGRAPixelTransparent*: TBGRAPixel;
6+
7+This is the value used for transparent pixels. In theory, any color with alpha = 0 is transparent, however it is recommended to use all other channels to zero as well.
8+
9+*BGRAWhite*: TBGRAPixel;
10+
11+White opaque
12+
13+*BGRABlack*: TBGRAPixel;
14+
15+Black opaque
16+
17+*clBlackOpaque* = TColor(\$010000);
18+
19+This color looks just like black. It is needed for drawing black shapes using the *Canvas* property of TBGRABitmap. This is a standard TCanvas and when drawing with pure black (*clBlack*), there is no way to know if something has been drawn or if it is transparent
20+
21+*TBGRAColorList* = **class**
22+
23+Contains a fixed list of colors
24+
25+**constructor** Create;
26+
27+Creates an empty color list
28+
29+**procedure** Add(Name: **string**; **const** Color: TBGRAPixel); **overload**;
30+
31+Add a color to the list
32+
33+**procedure** Finished;
34+
35+Ends the color list and prevents further modifications
36+
37+**function** IndexOf(Name: **string**): integer;
38+
39+Returns the index of a color with a given name
40+
41+**function** IndexOfColor(**const** AColor: TBGRAPixel; AMaxDiff: Word = 0): integer;
42+
43+Returns the index of a color. Colors are considered to match if the difference is less than or equal to *AMaxDiff*
44+
45+**property** ByName\[Name: **string**\]: TBGRAPixel **read** GetByName;
46+
47+Gets the color associated with a color name
48+
49+**property** ByIndex\[Index: integer\]: TBGRAPixel **read** GetByIndex; **default**;
50+
51+Gets the color at the specified index
52+
53+**property** Name\[Index: integer\]: **string** **read** GetName;
54+
55+Gets the name of the color at the specified index
56+
57+**property** Count: integer **read** FNbColors;
58+
59+Gets the number of colors
60+
61+*VGAColors*: TBGRAColorList;
62+
63+List of VGA colors:
64+
65+Black, Gray, Silver, White, Maroon, Red, Purple, Fuchsia, Green, Lime, Olive, Yellow, Navy, Blue, Teal, Aqua.
66+
67+Shortcut constants are provided: *VGABlack*, *VGAGray*...
68+
69+*CSSColors*: TBGRAColorList;
70+
71+List of [web colors](https://www.w3schools.com/cssref/css_colors.asp).
72+
73+Shortcut constants are provided: *CSSBlack*, *CSSRed*...
74+
75+**function** BGRAToStr(c: TBGRAPixel; AColorList: TBGRAColorList = **nil**;
76+
77+Converts a TBGRAPixel value into a string, using color names provided in *AColorList*, and considering that a color matches in the color list if its difference is within *AMaxDiff*
78+
79+**function** StrToBGRA(str: **string**): TBGRAPixel; **overload**;
80+
81+Converts a fully defined string into a TBGRAPixel value. Color names from *VGAColors* and *CSSColors* are used if there is an exact match
82+
83+**function** StrToBGRA(str: **string**; **const** DefaultColor: TBGRAPixel): TBGRAPixel; **overload**;
84+
85+Converts a string into a TBGRAPixel value. If the value is not fully defined or that there is an error, *DefaultColor* is returned. Color names from *VGAColors* and *CSSColors* are used if there is an exact match.
86+
87+**function** PartialStrToBGRA(str: **string**; **const** fallbackValues: TBGRAPixel; **out** error: boolean): TBGRAPixel;
88+
89+Converts a string into a TBGRAPixel value. If the value is not fully defined, missing channels (expressed with '?') are filled with fallbackValues. You can check if there was an error with the provided boolean. Color names from *VGAColors* and *CSSColors* are used if there is an exact match.
90+
91+**procedure** TryStrToBGRA(str: **string**; **var** parsedValue: TBGRAPixel; **out** missingValues: boolean; **out** error: boolean);
92+
93+Converts a string into a TBGRAPixel value into *parsedValue*. *parsedValue* is not changed if some channels are missing (expressed with '?'). You can check if there was an error with the provided boolean. Color names from *VGAColors* and *CSSColors* are used if there is an exact match.
94+
4995## See also
5096
51- * [[BGRABitmap XYZ|Using XYZ colorspace in BGRABitmap]]
97+- [[BGRABitmap XYZ|Using XYZ colorspace in BGRABitmap]]
5298
5399---
54-*From the Free Pascal wiki, page "BGRABitmap Color definitions", as the Internet Archive kept it on 2025-05-15. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
100+*From the Free Pascal wiki, page "BGRABitmap Color definitions", as it stood on 2024-04-03 after a change by Circular, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
101+Category: BGRABitmap

Back to history