Declarations ​
procedure GammaBlur32(ASource, ADest: TBitmap32; Radius: TFloat); overload;
procedure GammaBlur32(Bitmap: TBitmap32; Radius: TFloat); overload;
procedure GammaBlur32(Bitmap: TBitmap32; Radius: TFloat; const Bounds: TRect); overload;
procedure GammaBlur32(Bitmap: TBitmap32; Radius: TFloat; const Region: TArrayOfFloatPoint); overload;Overload Details
Overload 1 ​
procedure GammaBlur32(ASource, ADest: TBitmap32; Radius: TFloat); overload;Blurs the source bitmap in linear light space and writes the result into the destination bitmap.
| Parameter | Type | Description |
|---|---|---|
ASource | TBitmap32 | Source 32-bit bitmap to read pixels from. |
ADest | TBitmap32 | Destination 32-bit bitmap to receive the blurred output. |
Radius | TFloat | Blur radius in pixels. |
Overload 2 ​
procedure GammaBlur32(Bitmap: TBitmap32; Radius: TFloat); overload;Blurs the entire bitmap in-place using linear light space.
| Parameter | Type | Description |
|---|---|---|
Bitmap | TBitmap32 | Bitmap to blur in-place. |
Radius | TFloat | Blur radius in pixels. |
Overload 3 ​
procedure GammaBlur32(Bitmap: TBitmap32; Radius: TFloat; const Bounds: TRect); overload;Blurs a rectangular sub-region of a bitmap in-place using linear light space.
| Parameter | Type | Description |
|---|---|---|
Bitmap | TBitmap32 | Bitmap containing the sub-region to blur. |
Radius | TFloat | Blur radius in pixels. |
Bounds | TRect | Bounding rectangle defining the target sub-region. |
Overload 4 ​
procedure GammaBlur32(Bitmap: TBitmap32; Radius: TFloat; const Region: TArrayOfFloatPoint); overload;Blurs an arbitrary polygonal region of a bitmap in-place using linear light space.
| Parameter | Type | Description |
|---|---|---|
Bitmap | TBitmap32 | Bitmap containing the polygonal region to blur. |
Radius | TFloat | Blur radius in pixels. |
Region | TArrayOfFloatPoint | Array of 2D floating-point points defining the polygon vertices. |
Description ​
GammaBlur32 performs gamma-aware Gaussian blurring on 32-bit ARGB bitmaps.
Unlike Blur32, which operates directly on non-linear sRGB pixel values, GammaBlur32 converts pixel channels into linear light space before applying the recursive filter passes, and converts the result back to sRGB space afterwards.
Why Use Gamma-Aware Blurring? ​
Standard blurring on non-linear sRGB pixels underestimates physical photon luminance along transitions between bright highlights and dark shadows. This results in noticeable dark fringe artifacts (a dark halo along white-on-black text or antialiased shapes).
By performing channel filtering in linear light space, GammaBlur32 ensures physically accurate light blending and clean, natural edge falloffs.
Example ​
var
Bmp: TBitmap32;
begin
Bmp := TBitmap32.Create;
try
Bmp.LoadFromFile('high_contrast_text.png');
// Perform gamma-correct Gaussian blur to avoid dark edge halos
GammaBlur32(Bmp, 8.0);
Bmp.SaveToFile('gamma_blurred.png');
finally
Bmp.Free;
end;
end;