瀏覽代碼

improved demo

Leandro Diaz 1 年之前
父節點
當前提交
f6d5feaab5
共有 2 個文件被更改,包括 38 次插入20 次删除
  1. 14 16
      test/test_bgravirtualscreen_blur/unit1.lfm
  2. 24 4
      test/test_bgravirtualscreen_blur/unit1.pas

+ 14 - 16
test/test_bgravirtualscreen_blur/unit1.lfm

@@ -1,26 +1,27 @@
 object Form1: TForm1
 object Form1: TForm1
   Left = 404
   Left = 404
-  Height = 629
+  Height = 768
   Top = 289
   Top = 289
-  Width = 1013
+  Width = 1024
   Caption = 'Form1'
   Caption = 'Form1'
-  ClientHeight = 629
-  ClientWidth = 1013
+  ClientHeight = 768
+  ClientWidth = 1024
   OnCreate = FormCreate
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   OnDestroy = FormDestroy
   OnResize = FormResize
   OnResize = FormResize
+  Position = poScreenCenter
   LCLVersion = '2.2.6.0'
   LCLVersion = '2.2.6.0'
   object BGRAVirtualScreen1: TBGRAVirtualScreen
   object BGRAVirtualScreen1: TBGRAVirtualScreen
     Left = 0
     Left = 0
-    Height = 629
+    Height = 768
     Top = 0
     Top = 0
-    Width = 1013
+    Width = 1024
     OnRedraw = BGRAVirtualScreen2Redraw
     OnRedraw = BGRAVirtualScreen2Redraw
     Align = alClient
     Align = alClient
     Alignment = taLeftJustify
     Alignment = taLeftJustify
     BevelOuter = bvRaised
     BevelOuter = bvRaised
-    ClientHeight = 629
-    ClientWidth = 1013
+    ClientHeight = 768
+    ClientWidth = 1024
     Color = clWhite
     Color = clWhite
     ParentColor = False
     ParentColor = False
     TabOrder = 0
     TabOrder = 0
@@ -32,7 +33,6 @@ object Form1: TForm1
       Width = 170
       Width = 170
       OnRedraw = BGRAVirtualScreen2Redraw
       OnRedraw = BGRAVirtualScreen2Redraw
       Alignment = taLeftJustify
       Alignment = taLeftJustify
-      BevelOuter = bvRaised
       ClientHeight = 224
       ClientHeight = 224
       ClientWidth = 170
       ClientWidth = 170
       Color = clWhite
       Color = clWhite
@@ -74,13 +74,12 @@ object Form1: TForm1
     end
     end
     object BGRAVirtualScreen3: TBGRAVirtualScreen
     object BGRAVirtualScreen3: TBGRAVirtualScreen
       Tag = 1
       Tag = 1
-      Left = 184
+      Left = 200
       Height = 224
       Height = 224
       Top = 8
       Top = 8
       Width = 170
       Width = 170
       OnRedraw = BGRAVirtualScreen2Redraw
       OnRedraw = BGRAVirtualScreen2Redraw
       Alignment = taLeftJustify
       Alignment = taLeftJustify
-      BevelOuter = bvRaised
       ClientHeight = 224
       ClientHeight = 224
       ClientWidth = 170
       ClientWidth = 170
       Color = clWhite
       Color = clWhite
@@ -684,15 +683,14 @@ object Form1: TForm1
     object BGRAVirtualScreen4: TBGRAVirtualScreen
     object BGRAVirtualScreen4: TBGRAVirtualScreen
       Tag = 1
       Tag = 1
       Left = 8
       Left = 8
-      Height = 352
+      Height = 491
       Top = 264
       Top = 264
-      Width = 992
+      Width = 1003
       OnRedraw = BGRAVirtualScreen2Redraw
       OnRedraw = BGRAVirtualScreen2Redraw
       Alignment = taLeftJustify
       Alignment = taLeftJustify
       Anchors = [akTop, akLeft, akRight, akBottom]
       Anchors = [akTop, akLeft, akRight, akBottom]
-      BevelOuter = bvRaised
-      ClientHeight = 352
-      ClientWidth = 992
+      ClientHeight = 491
+      ClientWidth = 1003
       Color = clWhite
       Color = clWhite
       ParentColor = False
       ParentColor = False
       TabOrder = 2
       TabOrder = 2

+ 24 - 4
test/test_bgravirtualscreen_blur/unit1.pas

@@ -6,7 +6,8 @@ interface
 
 
 uses
 uses
   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, BGRAVirtualScreen,
   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, BGRAVirtualScreen,
-  BCLabel, BGRABitmap, BCTypes, BCPanel, BCButton, BGRABitmapTypes, Types;
+  BCLabel, BGRABitmap, BCTypes, BCPanel, BCButton, BGRABitmapTypes, Types,
+  BCFilters;
 
 
 type
 type
 
 
@@ -31,6 +32,7 @@ type
     procedure FormResize(Sender: TObject);
     procedure FormResize(Sender: TObject);
   private
   private
     background: TBGRABitmap;
     background: TBGRABitmap;
+    backgroundnoise: TBGRABitmap;
     backgroundblur: TBGRABitmap;
     backgroundblur: TBGRABitmap;
   public
   public
 
 
@@ -47,17 +49,32 @@ implementation
 
 
 procedure TForm1.BGRAVirtualScreen2Redraw(Sender: TObject; Bitmap: TBGRABitmap);
 procedure TForm1.BGRAVirtualScreen2Redraw(Sender: TObject; Bitmap: TBGRABitmap);
 var
 var
-  blur: TBGRABitmap;
+  i: integer;
+  vs: TBGRAVirtualScreen;
+  shadow: TBGRABitmap;
 begin
 begin
   Bitmap.Fill(BGRABlack);
   Bitmap.Fill(BGRABlack);
   if TControl(Sender).Tag = 1 then
   if TControl(Sender).Tag = 1 then
   begin
   begin
     Bitmap.StretchPutImageProportionally(Rect(-TControl(Sender).Left,-TControl(Sender).Top,Width-TControl(Sender).Left,Height-TControl(Sender).Top), taCenter, tlCenter, backgroundblur, dmSet);
     Bitmap.StretchPutImageProportionally(Rect(-TControl(Sender).Left,-TControl(Sender).Top,Width-TControl(Sender).Left,Height-TControl(Sender).Top), taCenter, tlCenter, backgroundblur, dmSet);
-    Bitmap.Rectangle(0, 0, Bitmap.Width, Bitmap.Height, BGRA(255, 255, 255, 100), BGRA(255, 255, 255, 10), dmDrawWithTransparency);
+    Bitmap.RoundRectAntialias(0, 0, Bitmap.Width-1, Bitmap.Height-1, 5, 5, BGRA(255, 255, 255, 100), 1, BGRA(255, 255, 255, 10));
+    Bitmap.StretchPutImageProportionally(Rect(-TControl(Sender).Left,-TControl(Sender).Top,Width-TControl(Sender).Left,Height-TControl(Sender).Top), taCenter, tlCenter, backgroundnoise, dmDrawWithTransparency, 2);
   end
   end
   else
   else
   begin
   begin
+    shadow := TBGRABitmap.Create(Width, Height, BGRAPixelTransparent);
     Bitmap.StretchPutImageProportionally(Rect(0,0,Width,Height), taCenter, tlCenter,  background, dmSet);
     Bitmap.StretchPutImageProportionally(Rect(0,0,Width,Height), taCenter, tlCenter,  background, dmSet);
+    for i:=0 to TWinControl(Sender).ControlCount-1 do
+    begin
+      if (TWinControl(Sender).Controls[i] is TBGRAVirtualScreen) then
+      begin
+        vs := (TWinControl(Sender).Controls[i] as TBGRAVirtualScreen);
+        shadow.FillRect(vs.Left, vs.Top, vs.Left+vs.Width, vs.Top+vs.Height, BGRABlack, dmSet);
+      end;
+    end;
+    BGRAReplace(shadow, shadow.FilterBlurRadial(8, 8, rbBox));
+    Bitmap.PutImage(0, 0, shadow, dmDrawWithTransparency);
+    shadow.Free;
   end;
   end;
 end;
 end;
 
 
@@ -65,13 +82,16 @@ procedure TForm1.FormCreate(Sender: TObject);
 begin
 begin
   background := TBGRABitmap.Create('background.jpg');
   background := TBGRABitmap.Create('background.jpg');
   //BGRAReplace(background, background.Resample(Width, Height, rmFineResample));
   //BGRAReplace(background, background.Resample(Width, Height, rmFineResample));
-  backgroundblur := background.FilterBlurRadial(10, 10, rbBox);
+  backgroundblur := background.FilterBlurRadial(20, 20, rbBox);
+  backgroundnoise := TBGRABitmap.Create(Width, Height, BGRABlack);
+  NoiseBW(backgroundnoise);
 end;
 end;
 
 
 procedure TForm1.FormDestroy(Sender: TObject);
 procedure TForm1.FormDestroy(Sender: TObject);
 begin
 begin
   background.Free;
   background.Free;
   backgroundblur.Free;
   backgroundblur.Free;
+  backgroundnoise.Free;
 end;
 end;
 
 
 procedure TForm1.FormResize(Sender: TObject);
 procedure TForm1.FormResize(Sender: TObject);