Hi,
hat schon mal jemand auf OSX/iOS ein NSImage über das bestehende Canvas gezeichnet? Der Hintergrund ist der: Ich wollte gerne über den Browser eine Art einblendbares Halbtransparentes OSD packen und das geht mit Firemonkey ja nicht wirklich.
Delphi-Quellcode:
unit UOSD;
interface
uses System.Types, System.Classes, FMX.Graphics, FMX.Controls;
type
TOSD =
class(TControl)
protected
FBitmap: TBitmap;
FNativePaint: Boolean;
procedure Paint;
override;
procedure SetBitmap(
const ABitmap: TBitmap);
procedure SetNativePaint(
const ANativePaint: Boolean);
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
property Bitmap: TBitmap
read FBitmap
write SetBitmap;
property Opacity;
property NativePaint: Boolean
read FNativePaint
write SetNativePaint
default false;
end;
implementation
constructor TOSD.Create(AOwner: TComponent);
begin
inherited;
Width := 100;
Height := 100;
FBitmap := TBitmap.Create;
end;
destructor TOSD.Destroy;
begin
FBitmap.Free;
inherited;
end;
procedure TOSD.SetNativePaint(
const ANativePaint: Boolean);
begin
if FNativePaint <> ANativePaint
then
begin
FNativePaint := ANativePaint;
Repaint;
end;
end;
procedure TOSD.SetBitmap(
const ABitmap: TBitmap);
begin
FBitmap.Assign(ABitmap);
Repaint;
end;
//WindowHandleToPlatform(FForm.Handle).View
procedure TOSD.Paint;
var
DstRect: TRectF;
begin
{$IFDEF MACOS}
if FNativePaint
then
begin
exit;
end;
{$ENDIF}
DstRect := FBitmap.BoundsF;
DstRect.Fit(BoundsRect);
Canvas.DrawBitmap(FBitmap, FBitmap.BoundsF, DstRect, Opacity)
end;
end.
Peter