Skip to content
Member Filters
Show Inherited
Show Protected
Show abstract
GR32_Gamma🞂ApplyCustomGammaFunction

ApplyCustomGamma

Applies a custom lookup table or custom power-law gamma value to a color, pixel array, or bitmap.

Declarations ​

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

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

ParameterTypeDescription
ColorTColor32Input 32-bit ARGB color value.
GammaTableTGammaTable8BitCustom 256-byte gamma lookup table array.
TypeDescription
TColor32Transformed color value with original alpha channel preserved.

Overload 2 ​

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

ParameterTypeDescription
ColorPColor32ArrayPointer to contiguous array of TColor32 pixels.
LengthIntegerNumber of pixels to process in the array.
GammaTableTGammaTable8BitCustom 256-byte gamma lookup table array.

Overload 3 ​

pascal
procedure ApplyCustomGamma(Bitmap: TBitmap32; GammaTable: TGammaTable8Bit); overload;

Applies a custom 256-byte lookup table in-place to all pixels in a TBitmap32.

ParameterTypeDescription
BitmapTBitmap32Target bitmap to transform in-place.
GammaTableTGammaTable8BitCustom 256-byte gamma lookup table array.

Overload 4 ​

pascal
procedure ApplyCustomGamma(Bitmap: TBitmap32; Gamma: Double); overload;

Applies a specified power-law gamma exponent in-place to all pixels in a TBitmap32.

ParameterTypeDescription
BitmapTBitmap32Target bitmap to transform in-place.
GammaDoublePower-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 ​

pascal
var
  CustomTable: TGammaTable8Bit;
begin
  SetGamma(2.2, CustomTable);
  ApplyCustomGamma(MyBitmap, CustomTable);

  // Or directly pass a gamma exponent
  ApplyCustomGamma(MyBitmap, 1.8);
end;

See also ​