Skip to content
Member Filters
Show Inherited
Show Protected
Show abstract
GR32.Blur🞂GammaBlur32Routine

GammaBlur32

Blurs a 32-bit bitmap in linear light space to prevent dark fringe artifacts on high-contrast edges.

Declarations ​

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

pascal
procedure GammaBlur32(ASource, ADest: TBitmap32; Radius: TFloat); overload;

Blurs the source bitmap in linear light space and writes the result into the destination bitmap.

ParameterTypeDescription
ASourceTBitmap32Source 32-bit bitmap to read pixels from.
ADestTBitmap32Destination 32-bit bitmap to receive the blurred output.
RadiusTFloatBlur radius in pixels.

Overload 2 ​

pascal
procedure GammaBlur32(Bitmap: TBitmap32; Radius: TFloat); overload;

Blurs the entire bitmap in-place using linear light space.

ParameterTypeDescription
BitmapTBitmap32Bitmap to blur in-place.
RadiusTFloatBlur radius in pixels.

Overload 3 ​

pascal
procedure GammaBlur32(Bitmap: TBitmap32; Radius: TFloat; const Bounds: TRect); overload;

Blurs a rectangular sub-region of a bitmap in-place using linear light space.

ParameterTypeDescription
BitmapTBitmap32Bitmap containing the sub-region to blur.
RadiusTFloatBlur radius in pixels.
BoundsTRectBounding rectangle defining the target sub-region.

Overload 4 ​

pascal
procedure GammaBlur32(Bitmap: TBitmap32; Radius: TFloat; const Region: TArrayOfFloatPoint); overload;

Blurs an arbitrary polygonal region of a bitmap in-place using linear light space.

ParameterTypeDescription
BitmapTBitmap32Bitmap containing the polygonal region to blur.
RadiusTFloatBlur radius in pixels.
RegionTArrayOfFloatPointArray 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 ​

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

See also ​