AggPas - Anti-Grain Geomertry for Object Pascal

BitmapAlphaTransparency(bitmap, alpha): boolean

Description

Changes the Alpha transparency channel of pf32bit TBitmap to defined level.

After Delphi VCL converts TBitmap to pf32bit format, the Alpha transparency channel can be initialized with zeroes, which means transparent. So to make the image visible with TAgg2D API methods, the transparency level has to be set to some visible value.

Parameters

bitmap: TBitmap

Reference to non empty pf32bit TBitmap (or descendant).

alpha: byte

A new value of Alpha transparency [(transparent) 0..255 (opaque)].

Returns

If True, the Alpha transparency change was performed successfuly.

If False, something went wrong, maybe image is empty or is not in pf32bit format.

Example

procedure TForm1.FormCreate(Sender: TObject);
begin

  // Don't erase background (no flicker)
  ControlStyle := ControlStyle + [csOpaque];

  // Create TAgg2D vector engine instance for the whole life of TForm
  VG := TAgg2D.Create;

  // Convert to pf32bit
  Image1.Picture.Bitmap.PixelFormat := pf32bit;

  // Set Alpha Transparency to Full Visible
  BitmapAlphaTransparency(Image1.Picture.Bitmap, 255);

end;