umain.pas 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. unit umain;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
  6. BGRAVirtualScreen, BGRABitmap, BCTypes, BGRABitmapTypes;
  7. type
  8. { TForm1 }
  9. TForm1 = class(TForm)
  10. BGRAVirtualScreen1: TBGRAVirtualScreen;
  11. procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  12. procedure FormCreate(Sender: TObject);
  13. procedure FormDestroy(Sender: TObject);
  14. private
  15. { private declarations }
  16. public
  17. { public declarations }
  18. blurSize: integer;
  19. offset: TPoint;
  20. logo, logoShadow: TBGRABitmap;
  21. end;
  22. var
  23. Form1: TForm1;
  24. implementation
  25. {$R *.lfm}
  26. procedure SingleColor(Bitmap: TBGRABitmap; Color: TBGRAPixel);
  27. var
  28. i: integer;
  29. p: PBGRAPixel;
  30. begin
  31. p := Bitmap.Data;
  32. for i := Bitmap.NBPixels - 1 downto 0 do
  33. begin
  34. p^.red := Color.Red;
  35. p^.green := Color.Green;
  36. p^.blue := Color.Blue;
  37. Inc(p);
  38. end;
  39. end;
  40. function Shadow(Source: TBGRABitmap; Color: TBGRAPixel; Blur: integer): TBGRABitmap;
  41. begin
  42. Result := TBGRABitmap.Create(Source.Width + (2 * Blur), Source.Height + (2 * Blur));
  43. Result.PutImage(Blur, Blur, Source, dmDrawWithTransparency);
  44. SingleColor(Result, Color);
  45. BGRAReplace(Result, Result.FilterBlurRadial(Blur, rbFast));
  46. end;
  47. { TForm1 }
  48. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  49. begin
  50. Bitmap.PutImage(blurSize + offSet.x, blurSize + offset.y, logoShadow,
  51. dmDrawWithTransparency);
  52. Bitmap.PutImage(blurSize * 2, blurSize * 2, logo, dmDrawWithTransparency);
  53. end;
  54. procedure TForm1.FormCreate(Sender: TObject);
  55. begin
  56. blurSize := 5;
  57. offSet := Point(5, 5);
  58. logo := TBGRABitmap.Create('logo.png');
  59. logoShadow := Shadow(logo, BGRA(0, 200, 200, 255), blurSize);
  60. end;
  61. procedure TForm1.FormDestroy(Sender: TObject);
  62. begin
  63. logo.Free;
  64. logoShadow.Free;
  65. end;
  66. end.