unit1.pas 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. unit Unit1;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, Forms, Controls, Graphics, Dialogs, BCGradientButton,
  6. BCButton, BGRABitmap, BCTypes, BGRABitmapTypes;
  7. type
  8. { TForm1 }
  9. TForm1 = class(TForm)
  10. BCGradientButton1: TBCGradientButton;
  11. procedure BCGradientButton1BeforeRedraw(Sender: TObject; Bitmap: TBGRABitmap
  12. );
  13. procedure FormCreate(Sender: TObject);
  14. procedure FormDestroy(Sender: TObject);
  15. private
  16. bmp: TBGRABitmap;
  17. public
  18. end;
  19. var
  20. Form1: TForm1;
  21. implementation
  22. {$R *.lfm}
  23. { TForm1 }
  24. procedure TForm1.FormCreate(Sender: TObject);
  25. begin
  26. BCGradientButton1.BeginUpdate;
  27. BCGradientButton1.BorderSize := 4;
  28. BCGradientButton1.EndUpdate;
  29. bmp := TBGRABitmap.Create(Application.Location + 'image.png');
  30. end;
  31. procedure TForm1.FormDestroy(Sender: TObject);
  32. begin
  33. bmp.Free;
  34. end;
  35. procedure TForm1.BCGradientButton1BeforeRedraw(Sender: TObject;
  36. Bitmap: TBGRABitmap);
  37. begin
  38. Bitmap.Fill(clNavy);
  39. Bitmap.StretchPutImageProportionally(Rect(0, 0, Bitmap.Width, Bitmap.Height), TACenter, TLCenter, bmp, dmDrawWithTransparency);
  40. end;
  41. end.