Difference between revisions of "BGRABitmap Pixel types"

From Free Pascal wiki
Jump to navigationJump to search
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category: BGRABitmap]]
+
{{LanguageBar}}
 
 
{{MenuTranslate| page=BGRABitmap Pixel types}}
 
  
 
List of pixel types and functions of [[BGRABitmap]] library. They are provided by ''BGRABitmapTypes'' unit.
 
List of pixel types and functions of [[BGRABitmap]] library. They are provided by ''BGRABitmapTypes'' unit.
  
 
=== Pixel types and functions ===
 
=== Pixel types and functions ===
<table style="border-collapse: collapse;"><tr style="background: white;"><td colspan="3">''PBGRAPixel'' = ^TBGRAPixel;</td></tr>
+
<table style="border-collapse: collapse;">
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Pointer for direct pixel access. Data is stored as a sequence of ''TBGRAPixel''. See [[BGRABitmap tutorial 4]]</td></tr>
+
<tr style="background: white;"><td colspan="3">''PBGRAPixel'' = ^TBGRAPixel;</td></tr>
 +
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Pointer for direct pixel access. Data is stored as a sequence of TBGRAPixel. See [[BGRABitmap_tutorial_4|Tutorial 4]]</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">''TBGRAPixel'' = '''packed''' '''record''' blue, green, red, alpha: byte;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">''TBGRAPixel'' = '''packed''' '''record'''</td></tr>
 
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Each pixel is a sequence of 4 bytes containing blue, green, red and alpha channel. Values range from 0 to 255, color is in sRGB colorspace. The alpha value of 0 is transparent and 255 is opaque. In the bitmap data, when the pixel is fully transparent, the RGB values are supposed to be set to zero.</td></tr>
 
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Each pixel is a sequence of 4 bytes containing blue, green, red and alpha channel. Values range from 0 to 255, color is in sRGB colorspace. The alpha value of 0 is transparent and 255 is opaque. In the bitmap data, when the pixel is fully transparent, the RGB values are supposed to be set to zero.</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' BGRA(red, green, blue, alpha: byte): TBGRAPixel; '''overload'''; '''inline''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''red'', ''green'', ''blue'', ''alpha'': byte;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates a pixel with given RGBA values</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Fields if ordered RGBA ordered</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' BGRA(red, green, blue: byte): TBGRAPixel; '''overload'''; '''inline''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''blue'', ''green'', ''red'', ''alpha'': byte;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates a opaque pixel with given RGB values</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Fields if ordered BGRA ordered</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''operator''' = ('''const''' c1, c2: TBGRAPixel): boolean; '''inline''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''procedure''' FromRGB(ARed,AGreen,ABlue: Byte; AAlpha: Byte = 255);</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Checks if two pixels are equal. If they are both transparent, RGB values are ignored</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Sets the pixel with given RGB values</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' GetIntensity(c: TBGRAPixel): word; '''inline''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''procedure''' FromColor(AColor: TColor; AAlpha: Byte = 255);</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the intensity of a pixel. The intensity is the maximum value reached by any component</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Sets the pixel with given TColor</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' SetIntensity(c: TBGRAPixel; intensity: word): TBGRAPixel;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''procedure''' FromString(AStr: '''string''');</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Sets the intensity of a pixel</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Sets the pixel according to a color name or CSS expression</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' GetLightness(c: TBGRAPixel): word;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''procedure''' FromFPColor(AColor: TFPColor);</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the lightness of a pixel. The lightness is the perceived brightness, 0 being black and 65535 being white</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Sets the pixel with given TFPColor  (16-bit per channel)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' SetLightness(c: TBGRAPixel; lightness: word): TBGRAPixel;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''procedure''' ToRGB('''out''' ARed,AGreen,ABlue,AAlpha: Byte); '''overload''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Sets the lightness of a pixel</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Extras RGBA channels</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' ApplyLightnessFast(color: TBGRAPixel; lightness: word): TBGRAPixel; '''inline''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''procedure''' ToRGB('''out''' ARed,AGreen,ABlue: Byte); '''overload''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Sets the lightness quickly, by fading towards black if ''lightness'' is less than 32768, and fading towards white if ''lightness'' is more than 32768</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Extras RGB channels</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' ApplyIntensityFast(color: TBGRAPixel; lightness: longword): TBGRAPixel;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' ToColor: TColor;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Sets the intensity quickly, by fading towards black if ''lightness'' is less than 32768, and multiplying all components if ''lightness'' is more than 32768. In case of saturation, it fades towards white</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts to TColor</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' CombineLightness(lightness1,lightness2: Int32or64): Int32or64;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' ToString: '''string''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Combines two lightnesses together. A value of 32768 is neutral. The result may exceed 65535</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts to a CSS string representation</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' BGRAToGrayscale(c: TBGRAPixel): TBGRAPixel;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' ToGrayscale(AGammaCorrection: boolean = true): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a color into grayscale</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Compute grayscale equivalent</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' GrayscaleToBGRA(lightness: word): TBGRAPixel;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' ToFPColor: TFPColor;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Create a gray color with the given ''lightness''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts to TFPColor (16-bit per channel)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' MergeBGRA(c1, c2: TBGRAPixel): TBGRAPixel; '''overload''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' EqualsExactly(constref AColor: TBGRAPixel): boolean;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Merge two colors without gamma correction</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Check whether all channels are equal (this is generally not necessary to use this fonction unless the RGB value of a transparent color matter)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' MergeBGRA(c1: TBGRAPixel; weight1: integer; c2: TBGRAPixel; weight2: integer): TBGRAPixel; '''overload''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''class''' '''operator''' := (Source: TBGRAPixel): TColor;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Merge two colors without gamma correction. ''weight1'' and ''weight2'' indicates the weight of the color barycentre</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Assign a TBGRAPixel to a TColor</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' MergeBGRAWithGammaCorrection(c1: TBGRAPixel; weight1: byte; c2: TBGRAPixel; weight2: byte): TBGRAPixel;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''class''' '''operator''' := (Source: TColor): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Merge two colors with gamma correction. ''weight1'' and ''weight2'' indicates the weight of the color barycentre</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Assign a TColor to a TBGRAPixel</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' ColorToBGRA(color: TColor): TBGRAPixel; '''overload''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''property''' Intensity: word '''read''' GetClassIntensity '''write''' SetClassIntensity;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a ''TColor'' value into an opaque pixel</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Intensity of the color (how much channels are saturated)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' ColorToBGRA(color: TColor; opacity: byte): TBGRAPixel; '''overload''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''property''' Lightness: word '''read''' GetClassLightness '''write''' SetClassLightness;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a ''TColor'' value into a pixel with given ''opacity''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Lightness of the color (the resulting lightness of combined channels)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' BGRAToColor(c: TBGRAPixel): TColor;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''operator''' = ('''const''' c1, c2: TBGRAPixel): boolean; '''inline''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel into a TColor value, discarding the alpha value</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Checks if two pixels are equal. If they are both transparent, RGB values are ignored</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' FPColorToBGRA(AValue: TFPColor): TBGRAPixel;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''const''' TBGRAPixel_RGBAOrder = False;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a ''TFPColor'' value into a pixel. Note that even if ''TFPColor'' have 16-bit values, they are not considered as gamma expanded</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Order of the channels (when BGRA)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' BGRAToFPColor(AValue: TBGRAPixel): TFPColor; '''inline''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''const''' TBGRAPixel_BlueByteOffset = 0;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel into a ''TFPColor''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Offset of the blue channel (when BGRA)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' BGRAWordDiff(c1, c2: TBGRAPixel): word;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''const''' TBGRAPixel_GreenByteOffset = 1;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Computes the difference (with gamma correction) between two pixels, taking into account all dimensions, including transparency. The result ranges from 0 to 65535</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Offset of the green channel (when BGRA)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' BGRADiff(c1, c2: TBGRAPixel): byte;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''const''' TBGRAPixel_RedByteOffset = 2;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Computes the difference (with gamma correction) between two pixels, taking into account all dimensions, including transparency. The result ranges from 0 to 255</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Offset of the blue channel (when BGRA)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">''ArrayOfTBGRAPixel'' = '''array''' '''of''' TBGRAPixel;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''const''' TBGRAPixel_AlphaByteOffset = 3;</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Array of pixels</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Offset of the alpha channel</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' MergeBGRA('''const''' colors: '''array''' '''of''' TBGRAPixel): TBGRAPixel; '''overload''';</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' BGRA(red, green, blue, alpha: byte): TBGRAPixel; '''overload'''; '''inline''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Merge given colors without gamma correction</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Creates a pixel with given RGBA values</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">''TExpandedPixel'' = '''packed''' '''record''' red, green, blue, alpha: word;</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' BGRA(red, green, blue: byte): TBGRAPixel; '''overload'''; '''inline''';</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Stores a gamma expanded RGB color. Values range from 0 to 65535</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Creates a opaque pixel with given RGB values</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' GammaExpansion(c: TBGRAPixel): TExpandedPixel; '''inline''';</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' GetIntensity(c: TBGRAPixel): word; '''inline''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from sRGB to gamma expanded RGB</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Returns the intensity of a pixel. The intensity is the maximum value reached by any component</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' GammaCompression('''const''' ec: TExpandedPixel): TBGRAPixel; '''inline''';</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' SetIntensity(c: TBGRAPixel; intensity: word): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from gamma expanded RGB to sRGB</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Sets the intensity of a pixel</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' GammaCompression(red,green,blue,alpha: word): TBGRAPixel; '''inline''';</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' GetLightness(c: TBGRAPixel): word; '''overload''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from gamma expanded RGB to sRGB</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Returns the lightness of a pixel. The lightness is the perceived brightness, 0 being black and 65535 being white</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' GetIntensity('''const''' c: TExpandedPixel): word; '''inline''';</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' SetLightness(c: TBGRAPixel; lightness: word): TBGRAPixel; '''overload''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the intensity of an gamma-expanded pixel. The intensity is the maximum value reached by any component</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Sets the lightness of a pixel</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' SetIntensity('''const''' c: TExpandedPixel; intensity: word): TExpandedPixel;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' ApplyLightnessFast(color: TBGRAPixel; lightness: word): TBGRAPixel; '''inline''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Sets the intensity of a gamma-expanded pixel</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Sets the lightness quickly, by fading towards black if ''lightness'' is less than 32768, and fading towards white if ''lightness'' is more than 32768</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' GetLightness('''const''' c: TExpandedPixel): word; '''inline''';</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' ApplyIntensityFast(color: TBGRAPixel; lightness: LongWord): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the lightness of an gamma-expanded pixel. The lightness is the perceived brightness, 0 being black and 65535 being white</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Sets the intensity quickly, by fading towards black if ''lightness'' is less than 32768, and multiplying all components if ''lightness'' is more than 32768. In case of saturation, it fades towards white</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' SetLightness('''const''' c: TExpandedPixel; lightness: word): TExpandedPixel;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' CombineLightness(lightness1,lightness2: Int32or64): Int32or64;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Sets the lightness of a gamma-expanded pixel</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Combines two lightnesses together. A value of 32768 is neutral. The result may exceed 65535</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' SetLightness('''const''' c: TExpandedPixel; lightness: word; curLightness: word): TExpandedPixel;</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' BGRAToGrayscale(c: TBGRAPixel): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Sets the lightness of a gamma expanded pixel, provided you already know the current value of lightness ''curLightness''. It is a bit faster than the previous function</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Converts a color into grayscale</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' ColorImportance(ec: TExpandedPixel): word;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' BGRAToGrayscaleLinear(c: TBGRAPixel): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the importance of the color. It is similar to saturation in HSL colorspace, except it is gamma corrected. A value of zero indicates a black/gray/white, and a value of 65535 indicates a bright color</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Converts a color into grayscale assuming linear colorspace</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' MergeBGRA(ec1, ec2: TExpandedPixel): TExpandedPixel; '''overload''';</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' GrayscaleToBGRA(lightness: word): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Merge two gamma expanded pixels (so taking into account gamma correction)</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Create a gray color with the given ''lightness''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' ExpandedDiff(ec1, ec2: TExpandedPixel): word;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' MergeBGRA(c1, c2: TBGRAPixel): TBGRAPixel; '''overload''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Computes the difference (with gamma correction) between two pixels, taking into account all dimensions, including transparency. The result ranges from 0 to 65535</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Merge two colors without gamma correction</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">''THSLAPixel'' = '''packed''' '''record'''</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' MergeBGRA(c1: TBGRAPixel; weight1: integer; c2: TBGRAPixel; weight2: integer): TBGRAPixel; '''overload''';</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Pixel color defined in HSL colorspace. Values range from 0 to 65535</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Merge two colors without gamma correction. ''weight1'' and ''weight2'' indicates the weight of the color barycentre</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''hue'': word;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' MergeBGRAWithGammaCorrection(c1: TBGRAPixel; weight1: byte; c2: TBGRAPixel; weight2: byte): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Hue of the pixel. Extremum values 0 and 65535 are red</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Merge two colors with gamma correction. ''weight1'' and ''weight2'' indicates the weight of the color barycentre</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''saturation'': word;</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' ColorToBGRA(color: TColor): TBGRAPixel; '''overload''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Saturation of the color. 0 is gray and 65535 is the brightest color</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Converts a TColor value into an opaque pixel</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''lightness'': word;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' ColorToBGRA(color: TColor; opacity: byte): TBGRAPixel; '''overload''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Lightness of the color. 0 is black, 32768 is normal, and 65535 is white</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Converts a TColor value into a pixel with given ''opacity''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''alpha'': word;</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' BGRAToColor(c: TBGRAPixel): TColor;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Opacity of the pixel. 0 is transparent and 65535 is opaque</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Converts a pixel into a TColor value, discarding the alpha value</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' HSLA(hue, saturation, lightness, alpha: word): THSLAPixel; '''overload'''; '''inline''';</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' FastRoundDiv257(valueWord: LongWord): byte; '''inline''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates a pixel with given HSLA values, where A stands for alpha</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Fonction to divide by 257 (not quite the same as '''shr''' 8)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' HSLA(hue, saturation, lightness: word): THSLAPixel; '''overload'''; '''inline''';</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' FPColorToBGRA(AValue: TFPColor): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates an opaque pixel with given HSL values</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Converts a TFPColor value into a pixel. Note that even if TFPColor have 16-bit values, they are not considered as gamma expanded</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' BGRAToHSLA(c: TBGRAPixel): THSLAPixel;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' BGRAToFPColor(AValue: TBGRAPixel): TFPColor; '''inline''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from sRGB to HSL color space</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Converts a pixel into a TFPColor</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' ExpandedToHSLA('''const''' ec: TExpandedPixel): THSLAPixel;</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' Color16BitToBGRA(AColor: Word): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from gamma expanded RGB to HSL color space</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Converts a 16-bit packed color into a TBGRAPixel</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' HSLAToExpanded('''const''' c: THSLAPixel): TExpandedPixel;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' BGRAToColor16Bit('''const''' AColor: TBGRAPixel): Word;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from HSL colorspace to gamma expanded RGB</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Converts a TBGRAPixel into a 16-bit packed color</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' HSLAToBGRA('''const''' c: THSLAPixel): TBGRAPixel;</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' BGRAWordDiff(c1, c2: TBGRAPixel): word;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from HSL colorspace to sRGB</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Computes the difference (with gamma correction) between two pixels, taking into account all dimensions, including transparency. The result ranges from 0 to 65535</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' HueDiff(h1, h2: word): word;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' BGRADiff(c1, c2: TBGRAPixel): byte;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Computes the hue difference</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Computes the difference (with gamma correction) between two pixels, taking into account all dimensions, including transparency. The result ranges from 0 to 255</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' GetHue(ec: TExpandedPixel): word;</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' FastBGRALinearDiff(c1,c2: TBGRAPixel): byte;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the hue of a gamma expanded pixel</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Fast computation of difference, without weighing the alpha channel and without gamma correction</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">''TGSBAPixel'' = THSLAPixel;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' FastBGRAExpandedDiff(c1,c2: TBGRAPixel): word;</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Pixel color defined in corrected HSL colorspace. G stands for corrected hue and B stands for actual brightness. Values range from 0 to 65535</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Fast computation of difference, without weighing the alpha channel</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' BGRAToGSBA(c: TBGRAPixel): TGSBAPixel;</td></tr>
+
<tr style="background: white;"><td colspan="3">'''function''' MapHeight(Color: TBGRAPixel): Single;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from sRGB to correct HSL color space</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Get height [0..1] stored in a TBGRAPixel</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' ExpandedToGSBA(ec: TExpandedPixel): TGSBAPixel;</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' MapHeightToBGRA(Height: Single; Alpha: Byte): TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from gamma expanded RGB to correct HSL color space</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Get TBGRAPixel to store height [0..1]</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' GtoH(ghue: word): word;</td></tr>
+
<tr style="background: white;"><td colspan="3">''TBGRAPixelBuffer'' = '''packed''' '''array''' '''of''' TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a G hue (GSBA) to a H hue (HSLA)</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Array of TBGRAPixel to be used as a buffer</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' HtoG(hue: word): word;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''procedure''' AllocateBGRAPixelBuffer('''var''' ABuffer: TBGRAPixelBuffer; ASize: integer);</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a H hue (HSLA) to a G hue (GSBA)</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Allocate a buffer of TBGRAPixel</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' GSBAToBGRA(c: TGSBAPixel): TBGRAPixel;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''ArrayOfTBGRAPixel'' = '''array''' '''of''' TBGRAPixel;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from corrected HSL to sRGB</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Array of pixels, not to be used as a buffer</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' GSBAToExpanded(c: TGSBAPixel): TExpandedPixel;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' MergeBGRA('''const''' colors: '''array''' '''of''' TBGRAPixel): TBGRAPixel; '''overload''';</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from correct HSL to gamma expanded RGB</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Merge given colors without gamma correction</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' GSBAToHSLA(c: TGSBAPixel): THSLAPixel;</td></tr>
+
<tr style="background: white;"><td colspan="3">''TDrawMode'' = (</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Converts a pixel from correct HSL to usual HSL</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Possible modes when drawing a pixel over another one</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">''TColorF'' = '''packed''' '''array'''[1..4] '''of''' single;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''dmSet'',</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">General purpose color variable with single-precision floating point values</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The pixel is replaced</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' ColorF(red,green,blue,alpha: single): TColorF;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''dmSetExceptTransparent'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates a TColorF structure</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The pixel is replaced if the pixel over has an alpha value of 255</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''operator''' - ('''const''' c1, c2: TColorF): TColorF; '''inline''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''dmLinearBlend'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Subtract each component separately</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The pixel is blend over the other one according to alpha values, however no gamma correction is applied. In other words, the color space is assumed to be linear</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''operator''' + ('''const''' c1, c2: TColorF): TColorF; '''inline''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''dmDrawWithTransparency'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Add each component separately</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The pixel is blend over the other one according to alpha values, and a gamma correction is applied. In other word, the color space is assumed to be sRGB</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''operator''' * ('''const''' c1, c2: TColorF): TColorF; '''inline''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''dmXor'');</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Multiply each component separately</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Values of all channels are combined with Xor. This is useful to compute the binary difference, however it is not something that makes much sense to display on the screen</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''operator''' * ('''const''' c1: TColorF; factor: single): TColorF; '''inline''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''dmFastBlend'' = dmLinearBlend;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Multiply each component by ''factor''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">An alias for the linear blend, because it is faster than blending with gamma correction</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">''TDrawMode'' = (</td></tr>
+
<tr style="background: #f0f0ff;"><td colspan="3">''TBlendOperation'' = (</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Possible modes when drawing a pixel over another one</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Advanced blending modes. See [http://www.brighthub.com/multimedia/photography/articles/18301.aspx Paint.NET blend modes] and [http://www.pegtop.net/delphi/articles/blendmodes/ Formulas]. Blending layers has two steps. The first one is to apply the blend operations listed below, and the second is the actual merging of the colors</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''dmSet'',</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boLinearBlend'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The pixel is replaced</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Simple blend, except that it forces a linear merge so it is equivalent to ''dmLinearBlend''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''dmSetExceptTransparent'',</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boTransparent'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The pixel is replaced if the pixel over has an alpha value of 255</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Simple blend. It is equivalent to ''dmLinearBlend'' or ''dmDrawWithTransparency''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''dmLinearBlend'',</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boLighten'', ''boScreen'', ''boAdditive'', ''boLinearAdd'', ''boColorDodge'', ''boDivide'', ''boNiceGlow'', ''boSoftLight'', ''boHardLight'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The pixel is blend over the other one according to alpha values, however no gamma correction is applied. In other words, the color space is assumed to be linear</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Lighting blend modes (tends to increase the luminosity)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''dmDrawWithTransparency'',</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boGlow'', ''boReflect'', ''boOverlay'', ''boDarkOverlay'', ''boDarken'', ''boMultiply'', ''boColorBurn'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The pixel is blend over the other one according to alpha values, and a gamma correction is applied. In other word, the color space is assumed to be sRGB</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Masking blend modes (tends to decrease the luminosity)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''dmXor'');</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boDifference'', ''boLinearDifference'', ''boExclusion'', ''boLinearExclusion'', ''boSubtract'', ''boLinearSubtract'', ''boSubtractInverse'', ''boLinearSubtractInverse'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Values of all channels are combined with Xor. This is useful to compute the binary difference, however it is not something that makes much sense to display on the screen</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Difference blend modes</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''dmFastBlend'' = dmLinearBlend;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boNegation'', ''boLinearNegation'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">An alias for the linear blend, because it is faster than blending with gamma correction</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Negation blend modes</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">''TBlendOperation'' = (</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boXor'',</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Advanced blending modes. See [http://www.brighthub.com/multimedia/photography/articles/18301.aspx Paint.NET blend modes] and [http://www.pegtop.net/delphi/articles/blendmodes/ Formulas]. Blending layers has two steps. The first one is to apply the blend operations listed below, and the second is the actual merging of the colors</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Xor blend mode. It is sightly different from ''dmXor'' because the alpha value is used like in other blends modes</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boLinearBlend'',</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boSvgSoftLight'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Simple blend, except that it forces a linear merge so it is equivalent to ''dmLinearBlend''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">SVG implementation of soft light</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boTransparent'',</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boMask'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Simple blend. It is equivalent to ''dmLinearBlend'' or ''dmDrawWithTransparency''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Apply mask</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boLighten'', boScreen, boAdditive, boLinearAdd, boColorDodge, boDivide, boNiceGlow, boSoftLight, boHardLight,</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boLinearMultiplySaturation'', ''boLinearHue'', ''boLinearColor'', ''boLinearLightness'', ''boLinearSaturation'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Lighting blend modes (tends to increase the luminosity)</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Standard HSL colorspace</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boGlow'', boReflect, boOverlay, boDarkOverlay, boDarken, boMultiply, boColorBurn,</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boCorrectedHue'', ''boCorrectedColor'', ''boCorrectedLightness'', ''boCorrectedSaturation''</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Masking blend modes (tends to decrease the luminosity)</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Corrected HSL colorspace (GSB)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boDifference'', boLinearDifference, boExclusion, boLinearExclusion, boSubtract, boLinearSubtract, boSubtractInverse, boLinearSubtractInverse,</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boGlowMask'' = boGlow;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Difference blend modes</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Alias to glow that express that this blend mode masks the part where the top layer is black</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boNegation'', boLinearNegation,</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boLinearMultiply'' = boMultiply;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Negation blend modes</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Alias because linear or non linear multiply modes are identical</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boXor'');</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boNonLinearOverlay'' = boDarkOverlay;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Xor blend mode. It is sightly different from ''dmXor'' because the alpha value is used like in other blends modes</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Alias to express that dark overlay is simply an overlay with gamma correction</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boGlowMask'' = boGlow;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''BlendOperationStr'' : '''array'''[TBlendOperation] '''of''' '''string'''</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Alias to glow that express that this blend mode masks the part where the top layer is black</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">String constants for blend modes</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''boLinearMultiply'' = boMultiply;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' StrToBlendOperation(str: '''string'''): TBlendOperation;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Alias because linear or non linear multiply modes are identical</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the blend mode expressed by the string</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''boNonLinearOverlay'' = boDarkOverlay;</td></tr>
+
<tr style="background: white;"><td colspan="3">''TAlphaChannelPaletteOption'' = (</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Alias to express that dark overlay is simply an overlay with gamma correction</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Specifies how a palette handles the alpha channel</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''BlendOperationStr'' : '''array'''[TBlendOperation] '''of''' '''string'''</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''acIgnore'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">String constants for blend modes</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The alpha channel is ignored. The alpha channel is considered to be stored elsewhere</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' StrToBlendOperation(str: '''string'''): TBlendOperation;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''acTransparentEntry'',</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the blend mode expressed by the string</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">One entry is allocated the fully transparent color</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">''TChannel'' = (cRed, cGreen, cBlue, cAlpha);</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''acFullChannelInPalette'');</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Possible channels in a bitmap using any RGBA colorspace</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The alpha channel is fully embedded in the palette so that a color is identified by its four RGBA channels</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''TChannels'' = set '''of''' TChannel;</td></tr>
+
<tr style="background: white;"><td colspan="3">''TDitheringAlgorithm'' = (</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Combination of channels</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Dithering algorithms that specifies how to handle colors that are not found in the palette</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">''TAlphaChannelPaletteOption'' = (</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''daNearestNeighbor'',</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Specifies how a palette handles the alpha channel</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The nearest color is to be used instead</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''acIgnore'',</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''daFloydSteinberg'');</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The alpha channel is ignored. The alpha channel is considered to be stored elsewhere</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The nearest color may be used however another color may be used to compensate for the error, following Floyd-Steinberg algorithm</td></tr>
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''acTransparentEntry'',</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">One entry is allocated the fully transparent color</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: white;">''acFullChannelInPalette'');</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The alpha channel is fully embedded in the palette so that a color is identified by its four RGBA channels</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="background: #f0f0ff;"><td colspan="3">''TDitheringAlgorithm'' = (</td></tr>
 
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Dithering algorithms that specifies how to handle colors that are not found in the palette</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: white;">''daNearestNeighbor'',</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The nearest color is to be used instead</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''daFloydSteinberg'');</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The nearest color may be used however another color may be used to compensate for the error, following Floyd-Steinberg algorithm</td></tr>
 
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
</table>
 
</table>
 +
 +
[[Category: BGRABitmap]]

Latest revision as of 18:54, 14 December 2023

English (en) русский (ru)

List of pixel types and functions of BGRABitmap library. They are provided by BGRABitmapTypes unit.

Pixel types and functions

PBGRAPixel = ^TBGRAPixel;
Pointer for direct pixel access. Data is stored as a sequence of TBGRAPixel. See Tutorial 4
TBGRAPixel = packed record
Each pixel is a sequence of 4 bytes containing blue, green, red and alpha channel. Values range from 0 to 255, color is in sRGB colorspace. The alpha value of 0 is transparent and 255 is opaque. In the bitmap data, when the pixel is fully transparent, the RGB values are supposed to be set to zero.
red, green, blue, alpha: byte;
Fields if ordered RGBA ordered
blue, green, red, alpha: byte;
Fields if ordered BGRA ordered
procedure FromRGB(ARed,AGreen,ABlue: Byte; AAlpha: Byte = 255);
Sets the pixel with given RGB values
procedure FromColor(AColor: TColor; AAlpha: Byte = 255);
Sets the pixel with given TColor
procedure FromString(AStr: string);
Sets the pixel according to a color name or CSS expression
procedure FromFPColor(AColor: TFPColor);
Sets the pixel with given TFPColor (16-bit per channel)
procedure ToRGB(out ARed,AGreen,ABlue,AAlpha: Byte); overload;
Extras RGBA channels
procedure ToRGB(out ARed,AGreen,ABlue: Byte); overload;
Extras RGB channels
function ToColor: TColor;
Converts to TColor
function ToString: string;
Converts to a CSS string representation
function ToGrayscale(AGammaCorrection: boolean = true): TBGRAPixel;
Compute grayscale equivalent
function ToFPColor: TFPColor;
Converts to TFPColor (16-bit per channel)
function EqualsExactly(constref AColor: TBGRAPixel): boolean;
Check whether all channels are equal (this is generally not necessary to use this fonction unless the RGB value of a transparent color matter)
class operator := (Source: TBGRAPixel): TColor;
Assign a TBGRAPixel to a TColor
class operator := (Source: TColor): TBGRAPixel;
Assign a TColor to a TBGRAPixel
property Intensity: word read GetClassIntensity write SetClassIntensity;
Intensity of the color (how much channels are saturated)
property Lightness: word read GetClassLightness write SetClassLightness;
Lightness of the color (the resulting lightness of combined channels)
operator = (const c1, c2: TBGRAPixel): boolean; inline;
Checks if two pixels are equal. If they are both transparent, RGB values are ignored
const TBGRAPixel_RGBAOrder = False;
Order of the channels (when BGRA)
const TBGRAPixel_BlueByteOffset = 0;
Offset of the blue channel (when BGRA)
const TBGRAPixel_GreenByteOffset = 1;
Offset of the green channel (when BGRA)
const TBGRAPixel_RedByteOffset = 2;
Offset of the blue channel (when BGRA)
const TBGRAPixel_AlphaByteOffset = 3;
Offset of the alpha channel
function BGRA(red, green, blue, alpha: byte): TBGRAPixel; overload; inline;
Creates a pixel with given RGBA values
function BGRA(red, green, blue: byte): TBGRAPixel; overload; inline;
Creates a opaque pixel with given RGB values
function GetIntensity(c: TBGRAPixel): word; inline;
Returns the intensity of a pixel. The intensity is the maximum value reached by any component
function SetIntensity(c: TBGRAPixel; intensity: word): TBGRAPixel;
Sets the intensity of a pixel
function GetLightness(c: TBGRAPixel): word; overload;
Returns the lightness of a pixel. The lightness is the perceived brightness, 0 being black and 65535 being white
function SetLightness(c: TBGRAPixel; lightness: word): TBGRAPixel; overload;
Sets the lightness of a pixel
function ApplyLightnessFast(color: TBGRAPixel; lightness: word): TBGRAPixel; inline;
Sets the lightness quickly, by fading towards black if lightness is less than 32768, and fading towards white if lightness is more than 32768
function ApplyIntensityFast(color: TBGRAPixel; lightness: LongWord): TBGRAPixel;
Sets the intensity quickly, by fading towards black if lightness is less than 32768, and multiplying all components if lightness is more than 32768. In case of saturation, it fades towards white
function CombineLightness(lightness1,lightness2: Int32or64): Int32or64;
Combines two lightnesses together. A value of 32768 is neutral. The result may exceed 65535
function BGRAToGrayscale(c: TBGRAPixel): TBGRAPixel;
Converts a color into grayscale
function BGRAToGrayscaleLinear(c: TBGRAPixel): TBGRAPixel;
Converts a color into grayscale assuming linear colorspace
function GrayscaleToBGRA(lightness: word): TBGRAPixel;
Create a gray color with the given lightness
function MergeBGRA(c1, c2: TBGRAPixel): TBGRAPixel; overload;
Merge two colors without gamma correction
function MergeBGRA(c1: TBGRAPixel; weight1: integer; c2: TBGRAPixel; weight2: integer): TBGRAPixel; overload;
Merge two colors without gamma correction. weight1 and weight2 indicates the weight of the color barycentre
function MergeBGRAWithGammaCorrection(c1: TBGRAPixel; weight1: byte; c2: TBGRAPixel; weight2: byte): TBGRAPixel;
Merge two colors with gamma correction. weight1 and weight2 indicates the weight of the color barycentre
function ColorToBGRA(color: TColor): TBGRAPixel; overload;
Converts a TColor value into an opaque pixel
function ColorToBGRA(color: TColor; opacity: byte): TBGRAPixel; overload;
Converts a TColor value into a pixel with given opacity
function BGRAToColor(c: TBGRAPixel): TColor;
Converts a pixel into a TColor value, discarding the alpha value
function FastRoundDiv257(valueWord: LongWord): byte; inline;
Fonction to divide by 257 (not quite the same as shr 8)
function FPColorToBGRA(AValue: TFPColor): TBGRAPixel;
Converts a TFPColor value into a pixel. Note that even if TFPColor have 16-bit values, they are not considered as gamma expanded
function BGRAToFPColor(AValue: TBGRAPixel): TFPColor; inline;
Converts a pixel into a TFPColor
function Color16BitToBGRA(AColor: Word): TBGRAPixel;
Converts a 16-bit packed color into a TBGRAPixel
function BGRAToColor16Bit(const AColor: TBGRAPixel): Word;
Converts a TBGRAPixel into a 16-bit packed color
function BGRAWordDiff(c1, c2: TBGRAPixel): word;
Computes the difference (with gamma correction) between two pixels, taking into account all dimensions, including transparency. The result ranges from 0 to 65535
function BGRADiff(c1, c2: TBGRAPixel): byte;
Computes the difference (with gamma correction) between two pixels, taking into account all dimensions, including transparency. The result ranges from 0 to 255
function FastBGRALinearDiff(c1,c2: TBGRAPixel): byte;
Fast computation of difference, without weighing the alpha channel and without gamma correction
function FastBGRAExpandedDiff(c1,c2: TBGRAPixel): word;
Fast computation of difference, without weighing the alpha channel
function MapHeight(Color: TBGRAPixel): Single;
Get height [0..1] stored in a TBGRAPixel
function MapHeightToBGRA(Height: Single; Alpha: Byte): TBGRAPixel;
Get TBGRAPixel to store height [0..1]
TBGRAPixelBuffer = packed array of TBGRAPixel;
Array of TBGRAPixel to be used as a buffer
procedure AllocateBGRAPixelBuffer(var ABuffer: TBGRAPixelBuffer; ASize: integer);
Allocate a buffer of TBGRAPixel
ArrayOfTBGRAPixel = array of TBGRAPixel;
Array of pixels, not to be used as a buffer
function MergeBGRA(const colors: array of TBGRAPixel): TBGRAPixel; overload;
Merge given colors without gamma correction
TDrawMode = (
Possible modes when drawing a pixel over another one
dmSet,
The pixel is replaced
dmSetExceptTransparent,
The pixel is replaced if the pixel over has an alpha value of 255
dmLinearBlend,
The pixel is blend over the other one according to alpha values, however no gamma correction is applied. In other words, the color space is assumed to be linear
dmDrawWithTransparency,
The pixel is blend over the other one according to alpha values, and a gamma correction is applied. In other word, the color space is assumed to be sRGB
dmXor);
Values of all channels are combined with Xor. This is useful to compute the binary difference, however it is not something that makes much sense to display on the screen
dmFastBlend = dmLinearBlend;
An alias for the linear blend, because it is faster than blending with gamma correction
TBlendOperation = (
Advanced blending modes. See Paint.NET blend modes and Formulas. Blending layers has two steps. The first one is to apply the blend operations listed below, and the second is the actual merging of the colors
boLinearBlend,
Simple blend, except that it forces a linear merge so it is equivalent to dmLinearBlend
boTransparent,
Simple blend. It is equivalent to dmLinearBlend or dmDrawWithTransparency
boLighten, boScreen, boAdditive, boLinearAdd, boColorDodge, boDivide, boNiceGlow, boSoftLight, boHardLight,
Lighting blend modes (tends to increase the luminosity)
boGlow, boReflect, boOverlay, boDarkOverlay, boDarken, boMultiply, boColorBurn,
Masking blend modes (tends to decrease the luminosity)
boDifference, boLinearDifference, boExclusion, boLinearExclusion, boSubtract, boLinearSubtract, boSubtractInverse, boLinearSubtractInverse,
Difference blend modes
boNegation, boLinearNegation,
Negation blend modes
boXor,
Xor blend mode. It is sightly different from dmXor because the alpha value is used like in other blends modes
boSvgSoftLight,
SVG implementation of soft light
boMask,
Apply mask
boLinearMultiplySaturation, boLinearHue, boLinearColor, boLinearLightness, boLinearSaturation,
Standard HSL colorspace
boCorrectedHue, boCorrectedColor, boCorrectedLightness, boCorrectedSaturation
Corrected HSL colorspace (GSB)
boGlowMask = boGlow;
Alias to glow that express that this blend mode masks the part where the top layer is black
boLinearMultiply = boMultiply;
Alias because linear or non linear multiply modes are identical
boNonLinearOverlay = boDarkOverlay;
Alias to express that dark overlay is simply an overlay with gamma correction
BlendOperationStr : array[TBlendOperation] of string
String constants for blend modes
function StrToBlendOperation(str: string): TBlendOperation;
Returns the blend mode expressed by the string
TAlphaChannelPaletteOption = (
Specifies how a palette handles the alpha channel
acIgnore,
The alpha channel is ignored. The alpha channel is considered to be stored elsewhere
acTransparentEntry,
One entry is allocated the fully transparent color
acFullChannelInPalette);
The alpha channel is fully embedded in the palette so that a color is identified by its four RGBA channels
TDitheringAlgorithm = (
Dithering algorithms that specifies how to handle colors that are not found in the palette
daNearestNeighbor,
The nearest color is to be used instead
daFloydSteinberg);
The nearest color may be used however another color may be used to compensate for the error, following Floyd-Steinberg algorithm