unit1.pas 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. unit Unit1;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  6. BGRAGraphicControl, BGRABitmap, BCTypes, BGRABitmapTypes;
  7. type
  8. { TForm1 }
  9. TForm1 = class(TForm)
  10. BGRAGraphicControl1: TBGRAGraphicControl;
  11. Timer1: TTimer;
  12. procedure BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  13. procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
  14. procedure FormCreate(Sender: TObject);
  15. procedure FormDestroy(Sender: TObject);
  16. procedure Timer1Timer(Sender: TObject);
  17. private
  18. { private declarations }
  19. public
  20. { public declarations }
  21. bkg: TBGRABitmap;
  22. end;
  23. var
  24. Form1: TForm1;
  25. implementation
  26. {$R *.lfm}
  27. { TForm1 }
  28. procedure TForm1.BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap
  29. );
  30. var
  31. i: integer;
  32. bmp: TBGRABitmap;
  33. begin
  34. //Bitmap.Fill(BGRABlack);
  35. Bitmap.FillTransparent;
  36. for i:= 0 to Bitmap.Width -1 do
  37. begin
  38. Bitmap.DrawVertLine(i,{Random(Bitmap.Height)}0,Random(Bitmap.Height),BGRA(255,255,255,Random(25)));
  39. Bitmap.DrawVertLine(i,Random(Bitmap.Height),Random(Bitmap.Height),BGRA(255,255,255,Random(50)));
  40. end;
  41. bmp := Bitmap.FilterBlurMotion(10,270,True) as TBGRABitmap;
  42. BGRAReplace(bmp, bmp.FilterBlurRadial(1,rbFast));
  43. Bitmap.BlendImageOver(0,0,bkg,boLinearBlend);
  44. Bitmap.BlendImageOver(0,0,bmp,boLinearBlend);
  45. bmp.Free;
  46. end;
  47. procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
  48. begin
  49. Timer1.Enabled := False;
  50. end;
  51. procedure TForm1.FormCreate(Sender: TObject);
  52. begin
  53. bkg := TBGRABitmap.Create('Lighthouse.jpg');
  54. end;
  55. procedure TForm1.FormDestroy(Sender: TObject);
  56. begin
  57. bkg.Free;
  58. end;
  59. procedure TForm1.Timer1Timer(Sender: TObject);
  60. begin
  61. BGRAGraphicControl1.DiscardBitmap;
  62. end;
  63. end.