Sign in Join
Wiki copytemporary

Revision 1 of 2, by Circular on 12-14-2023. The page as it is now.

BGRABitmap Pixel types

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

Pixel types and functions

<table style="border-collapse: collapse;">

<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 Tutorial 4

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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="height: 8px;">

<td colspan="3">

</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;">

Fields if ordered RGBA ordered

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Fields if ordered BGRA ordered

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Sets the pixel with given RGB values

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Sets the pixel with given TColor

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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 pixel according to a color name or CSS expression

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Sets the pixel with given TFPColor (16-bit per channel)

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Extras RGBA channels

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Extras RGB channels

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Converts to TColor

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Converts to a CSS string representation

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Compute grayscale equivalent

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Converts to TFPColor (16-bit per channel)

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

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>

<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;">

Assign a TBGRAPixel to a TColor

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Assign a TColor to a TBGRAPixel

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Intensity of the color (how much channels are saturated)

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Lightness of the color (the resulting lightness of combined channels)

</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: 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;">

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>

<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;">

Order of the channels (when BGRA)

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Offset of the blue channel (when BGRA)

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Offset of the green channel (when BGRA)

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Offset of the blue channel (when BGRA)

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</td>

</tr>

<tr>

<td width="10%">

</td>

<td colspan="2" style="background: white;">

const TBGRAPixel_AlphaByteOffset = 3;

</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="background: #f0f0ff;">

<td colspan="3">

function BGRA(red, green, blue, alpha: byte): TBGRAPixel; overload; inline;

</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="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">

Creates a opaque pixel with given RGB values

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</td>

</tr>

<tr style="background: #f0f0ff;">

<td colspan="3">

function GetIntensity(c: TBGRAPixel): word; inline;

</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="background: white;">

<td colspan="3">

function SetIntensity(c: TBGRAPixel; intensity: word): TBGRAPixel;

</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="background: #f0f0ff;">

<td colspan="3">

function GetLightness(c: TBGRAPixel): word; overload;

</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="background: white;">

<td colspan="3">

function SetLightness(c: TBGRAPixel; lightness: word): TBGRAPixel; overload;

</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="background: #f0f0ff;">

<td colspan="3">

function ApplyLightnessFast(color: TBGRAPixel; lightness: word): TBGRAPixel; inline;

</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="background: white;">

<td colspan="3">

function ApplyIntensityFast(color: TBGRAPixel; lightness: LongWord): TBGRAPixel;

</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="background: #f0f0ff;">

<td colspan="3">

function CombineLightness(lightness1,lightness2: Int32or64): Int32or64;

</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="background: white;">

<td colspan="3">

function BGRAToGrayscale(c: TBGRAPixel): TBGRAPixel;

</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="background: #f0f0ff;">

<td colspan="3">

function BGRAToGrayscaleLinear(c: TBGRAPixel): TBGRAPixel;

</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="background: white;">

<td colspan="3">

function GrayscaleToBGRA(lightness: word): TBGRAPixel;

</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="background: #f0f0ff;">

<td colspan="3">

function MergeBGRA(c1, c2: TBGRAPixel): TBGRAPixel; overload;

</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="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">

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="background: #f0f0ff;">

<td colspan="3">

function MergeBGRAWithGammaCorrection(c1: TBGRAPixel; weight1: byte; c2: TBGRAPixel; weight2: byte): TBGRAPixel;

</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="background: white;">

<td colspan="3">

function ColorToBGRA(color: TColor): TBGRAPixel; overload;

</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="background: #f0f0ff;">

<td colspan="3">

function ColorToBGRA(color: TColor; opacity: byte): TBGRAPixel; overload;

</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="background: white;">

<td colspan="3">

function BGRAToColor(c: TBGRAPixel): TColor;

</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="background: #f0f0ff;">

<td colspan="3">

function FastRoundDiv257(valueWord: LongWord): byte; inline;

</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="background: white;">

<td colspan="3">

function FPColorToBGRA(AValue: TFPColor): TBGRAPixel;

</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="background: #f0f0ff;">

<td colspan="3">

function BGRAToFPColor(AValue: TBGRAPixel): TFPColor; inline;

</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="background: white;">

<td colspan="3">

function Color16BitToBGRA(AColor: Word): TBGRAPixel;

</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="background: #f0f0ff;">

<td colspan="3">

function BGRAToColor16Bit(const AColor: TBGRAPixel): Word;

</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="background: white;">

<td colspan="3">

function BGRAWordDiff(c1, c2: TBGRAPixel): word;

</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="background: #f0f0ff;">

<td colspan="3">

function BGRADiff(c1, c2: TBGRAPixel): byte;

</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="background: white;">

<td colspan="3">

function FastBGRALinearDiff(c1,c2: TBGRAPixel): byte;

</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="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">

Fast computation of difference, without weighing the alpha channel

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</td>

</tr>

<tr style="background: white;">

<td colspan="3">

function MapHeight(Color: TBGRAPixel): Single;

</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="background: #f0f0ff;">

<td colspan="3">

function MapHeightToBGRA(Height: Single; Alpha: Byte): TBGRAPixel;

</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="background: white;">

<td colspan="3">

TBGRAPixelBuffer = packed array of TBGRAPixel;

</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>

<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;">

Allocate a buffer of TBGRAPixel

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Array of pixels, not to be used as a buffer

</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>

<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="background: white;">

<td colspan="3">

TDrawMode = (

</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>

<td width="10%">

</td>

<td colspan="2" style="background: #f0f0ff;">

dmSet,

</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>

<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;">

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>

<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;">

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>

<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;">

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>

<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;">

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>

<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;">

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="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">

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

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

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>

<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;">

Simple blend. It is equivalent to dmLinearBlend or dmDrawWithTransparency

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Lighting blend modes (tends to increase the luminosity)

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Masking blend modes (tends to decrease the luminosity)

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Difference blend modes

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Negation blend modes

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</td>

</tr>

<tr>

<td width="10%">

</td>

<td colspan="2" style="background: white;">

boXor,

</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>

<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;">

SVG implementation of soft light

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Apply mask

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Standard HSL colorspace

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Corrected HSL colorspace (GSB)

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

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>

<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;">

Alias because linear or non linear multiply modes are identical

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

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>

<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;">

String constants for blend modes

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</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;">

Returns the blend mode expressed by the string

</td>

</tr>

<tr style="height: 8px;">

<td colspan="3">

</td>

</tr>

<tr style="background: white;">

<td colspan="3">

TAlphaChannelPaletteOption = (

</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>

<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;">

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>

<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;">

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: #f0f0ff;">

acFullChannelInPalette);

</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="background: white;">

<td colspan="3">

TDitheringAlgorithm = (

</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>

<td width="10%">

</td>

<td colspan="2" style="background: #f0f0ff;">

daNearestNeighbor,

</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>

<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 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>

</table>


From the Free Pascal wiki, page "BGRABitmap Pixel types", as it stood on 2023-12-14 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.