Firemonkey:Image.Bitmap.DrawLine 在 ipad 上不可见

发布于 2024-12-25 11:06:09 字数 1040 浏览 0 评论 0原文

我正在 DelphiXE2 firemonkey 中为 IOS 构建一个应用程序。如果我在 Mac 上的 Xcode IPAD 模拟器中进行测试,我会看到该按钮。但是当我单击按钮时,看不到任何线条。为什么?

代码:(在表单上一个按钮和一个图像)

unit Unit3;

interface

uses
  SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
  FMX_Dialogs, FMX_Objects;

type
  TForm3 = class(TForm)
    Image1: TImage;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form3: TForm3;

implementation

{$R *.lfm}

procedure TForm3.Button1Click(Sender: TObject);
var pt0,pt1 : TPointF;
begin
  pt0.Create(0,0);
  pt1.Create(200,200);
  with Image1.Bitmap do begin
    Canvas.Stroke.Color := $ffff0000 ;  // Red
    Canvas.BeginScene;

    Canvas.DrawLine(pt0,pt1,1);
    BitmapChanged;  // without this, no output
    Canvas.EndScene;
  end;

end;


procedure TForm3.FormCreate(Sender: TObject);
begin
  Image1.Bitmap := TBitmap.Create(200,200);
end;
end.

I'm building a app in DelphiXE2 firemonkey for IOS. If I tested on the mac in the Xcode IPAD Simulator I saw the button. But when I click on the button no line is visible. Why?

code: (On the Form a button and a Image)

unit Unit3;

interface

uses
  SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
  FMX_Dialogs, FMX_Objects;

type
  TForm3 = class(TForm)
    Image1: TImage;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form3: TForm3;

implementation

{$R *.lfm}

procedure TForm3.Button1Click(Sender: TObject);
var pt0,pt1 : TPointF;
begin
  pt0.Create(0,0);
  pt1.Create(200,200);
  with Image1.Bitmap do begin
    Canvas.Stroke.Color := $ffff0000 ;  // Red
    Canvas.BeginScene;

    Canvas.DrawLine(pt0,pt1,1);
    BitmapChanged;  // without this, no output
    Canvas.EndScene;
  end;

end;


procedure TForm3.FormCreate(Sender: TObject);
begin
  Image1.Bitmap := TBitmap.Create(200,200);
end;
end.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱人如己 2025-01-01 11:06:09

我认为应该是:

pt0 := TPointF.Create(0, 0);

I think it should be:

pt0 := TPointF.Create(0, 0);
海拔太高太耀眼 2025-01-01 11:06:09

试试这个

  pt0.X:=X;
  pt0.Y:=Y;
  pt1.X:=X+4;
  pt1.Y:=Y+4;
  with Image1.Bitmap do begin
    Canvas.Stroke.Color := $ffff0000 ;  // Red
    Canvas.Stroke.Kind := TBrushKind.bkSolid;
    Canvas.StrokeThickness:= 10;
    Canvas.BeginScene;
    Canvas.DrawLine(pt0,pt1,100);
    Canvas.EndScene;
  end;

Try this

  pt0.X:=X;
  pt0.Y:=Y;
  pt1.X:=X+4;
  pt1.Y:=Y+4;
  with Image1.Bitmap do begin
    Canvas.Stroke.Color := $ffff0000 ;  // Red
    Canvas.Stroke.Kind := TBrushKind.bkSolid;
    Canvas.StrokeThickness:= 10;
    Canvas.BeginScene;
    Canvas.DrawLine(pt0,pt1,100);
    Canvas.EndScene;
  end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文