我怎样才能获得类似的空气效果'在OSX / Windows中使用FMX的delphi xe6? 我看到了这个教程,但它适用于VLC http://theroadtodelphi.wordpress.com/2009/10/26/glass-effect-in-a-delphi-console-application/
我正在寻找类似于航空的效果。更具体地说,效果使背景模糊。类似于您在iOS中看到的模糊叠加层。
所以我的表单需要是透明的,然后模糊该表单用于背景的图像。
感谢@RRUZ这是我到目前为止所拥有的。编译,但还没有完成工作:
unit test;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls
{$IFDEF MACOS32}
,FMX.Platform.Mac,
Macapi.CoreFoundation,
Macapi.CoreGraphics,
Macapi.AppKit,
Macapi.CocoaTypes
{$ENDIF}
;
{$IFDEF MACOS32}
type
CGSConnection = Pointer;
function CGSSetWindowBackgroundBlurRadius(connection: CGSConnection; windowNumber : NSInteger; radius : integer): CGError; cdecl; external libCoreGraphics name _PU + 'CGSSetWindowBackgroundBlurRadius';
function CGSDefaultConnectionForThread : CGSConnection ; cdecl; external libCoreGraphics name _PU + 'CGSDefaultConnectionForThread';
{$ENDIF}
type
TForm1 = class(TForm)
procedure FormShow(Sender: TObject);
private
{ Private declarations }
procedure enableBlurForWindow(Handle : TWindowHandle);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
{ TForm1 }
procedure TForm1.enableBlurForWindow(Handle: TWindowHandle);
var
connection : CGSConnection;
LNSWindow : NSWindow;
begin
LNSWindow:= WindowHandleToPlatform(Handle).Wnd;
LNSWindow.setOpaque(False);
LNSWindow.setBackgroundColor(TNSColor.Wrap(TNSColor.OCClass.colorWithCalibratedWhite(1.0, 0.5)));
connection := CGSDefaultConnectionForThread();
CGSSetWindowBackgroundBlurRadius(connection, LNSWindow.windowNumber, 20);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
enableBlurForWindow(Form1.Handle);
end;
end.
答案 0 :(得分:0)
在FMX应用程序中获得此效果比在VCL中简单得多,FMX带来特定组件以将效果应用于其他组件或表单(包括模糊效果)。
只需将组件放在表单上并激活它即可。