Declarations ​
function ApplyCustomGamma(Color: TColor32; GammaTable: TGammaTable8Bit): TColor32; overload;
procedure ApplyCustomGamma(Color: PColor32Array; Length: Integer; GammaTable: TGammaTable8Bit); overload;
procedure ApplyCustomGamma(Bitmap: TBitmap32; GammaTable: TGammaTable8Bit); overload;
procedure ApplyCustomGamma(Bitmap: TBitmap32; Gamma: Double); overload;Overload Details
Overload 1 ​
function ApplyCustomGamma(Color: TColor32; GammaTable: TGammaTable8Bit): TColor32; overload;Applies a custom 256-byte lookup table to the Red, Green, and Blue channels of a single TColor32 value.
| Parameter | Type | Description |
|---|---|---|
Color | TColor32 | Input 32-bit ARGB color value. |
GammaTable | TGammaTable8Bit | Custom 256-byte gamma lookup table array. |
| Type | Description |
|---|---|
TColor32 | Transformed color value with original alpha channel preserved. |
Overload 2 ​
procedure ApplyCustomGamma(Color: PColor32Array; Length: Integer; GammaTable: TGammaTable8Bit); overload;Applies a custom 256-byte lookup table in-place to a contiguous buffer array of TColor32 pixels.
| Parameter | Type | Description |
|---|---|---|
Color | PColor32Array | Pointer to contiguous array of TColor32 pixels. |
Length | Integer | Number of pixels to process in the array. |
GammaTable | TGammaTable8Bit | Custom 256-byte gamma lookup table array. |
Overload 3 ​
procedure ApplyCustomGamma(Bitmap: TBitmap32; GammaTable: TGammaTable8Bit); overload;Applies a custom 256-byte lookup table in-place to all pixels in a TBitmap32.
| Parameter | Type | Description |
|---|---|---|
Bitmap | TBitmap32 | Target bitmap to transform in-place. |
GammaTable | TGammaTable8Bit | Custom 256-byte gamma lookup table array. |
Overload 4 ​
procedure ApplyCustomGamma(Bitmap: TBitmap32; Gamma: Double); overload;Applies a specified power-law gamma exponent in-place to all pixels in a TBitmap32.
| Parameter | Type | Description |
|---|---|---|
Bitmap | TBitmap32 | Target bitmap to transform in-place. |
Gamma | Double | Power-law gamma exponent to apply. |
Description ​
ApplyCustomGamma transforms color channels using a custom TGammaTable8Bit lookup table or floating-point power-law exponent Gamma.
The 2-parameter bitmap overload ApplyCustomGamma(Bitmap, Gamma) checks whether GAMMA_VALUE matches Gamma. If GAMMA_VALUE = Gamma, it reuses GAMMA_ENCODING_TABLE directly for optimal performance; otherwise, it generates a temporary table via SetGamma and applies it to the bitmap.
Example ​
var
CustomTable: TGammaTable8Bit;
begin
SetGamma(2.2, CustomTable);
ApplyCustomGamma(MyBitmap, CustomTable);
// Or directly pass a gamma exponent
ApplyCustomGamma(MyBitmap, 1.8);
end;