Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Drawing on Image (canvas?) in XE6, iOS


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Feb 10, 2018 10:28 AM Last Post By: Alex Shy
Ian Johnson

Posts: 43
Registered: 3/14/06
Drawing on Image (canvas?) in XE6, iOS  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2014 11:33 PM
Hello,

I've been trying to figure out some very basic drawing stuff in XE6 for iOS. This example:

http://docwiki.embarcadero.com/CodeExamples/XE6/en/FMXTCanvasDrawFunctions_(Delphi)

is for XE2. It works fine when compiled to Win32, but when I try to run a similar thing for iOS, the FormCreate procedure throws an error. I had to change

Image1.Bitmap.Create(round(Image1.Width), round(Image1.Height));

to

Image1.Bitmap := TBitmap.Create(round(Image1.Width), round(Image1.Height));

This is fine, but it would be great if there were examples that are specific to XE6.

Once I got it going, I noticed that the ellipse quality is pretty poor, at least on the simulator.

So, I'd be really grateful if anyone could direct me to some documented examples for drawing good quality ellipses as well as lines of different thickness in FireMonkey for iOS, that are applicable to XE6.

Many thanks in advance,

Ian

Edited by: Ian Johnson on Jun 30, 2014 11:45 PM
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Drawing on Image (canvas?) in XE6, iOS  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 7:06 AM   in response to: Ian Johnson in response to: Ian Johnson
Includes special pen draw code for mobile and draw image on a paintbox. The same code works in XE5 and XE6 (I haven't had to change my image stamp code for XE6).
http://www.fmxexpress.com/cross-platform-firemonkey-drawing-app-demo/

http://www.fmxexpress.com/perfect-line-thickness-using-tcanvas-drawline-with-delphi-xe5-firemonkey-on-android-and-ios/

There is extensive drawing code in Box2D Firemonkey:
https://github.com/FMXExpress/box2d-firemonkey/blob/master/TestBed/TestBedShared/uDebugDrawerFM.pas

var
GPath: TPathData;

procedure TDebugDrawerFM.DrawEllipse(Canvas: TCanvas; aRect: TRectF; aOpacity: Single);
begin
// work around so ellipses don't crash on mobile
GPath.Clear;
GPath.AddEllipse(aRect);
Canvas.DrawPath(GPath, aOpacity);
end;
Ian Johnson

Posts: 43
Registered: 3/14/06
Re: Drawing on Image (canvas?) in XE6, iOS  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 7:31 PM   in response to: Eli M in response to: Eli M
Eli M wrote:
Includes special pen draw code for mobile and draw image on a paintbox. The same code works in XE5 and XE6 (I haven't had to change my image stamp code for XE6).
http://www.fmxexpress.com/cross-platform-firemonkey-drawing-app-demo/

http://www.fmxexpress.com/perfect-line-thickness-using-tcanvas-drawline-with-delphi-xe5-firemonkey-on-android-and-ios/

There is extensive drawing code in Box2D Firemonkey:
https://github.com/FMXExpress/box2d-firemonkey/blob/master/TestBed/TestBedShared/uDebugDrawerFM.pas

var
GPath: TPathData;

procedure TDebugDrawerFM.DrawEllipse(Canvas: TCanvas; aRect: TRectF; aOpacity: Single);
begin
// work around so ellipses don't crash on mobile
GPath.Clear;
GPath.AddEllipse(aRect);
Canvas.DrawPath(GPath, aOpacity);
end;

Thanks Eli - these are really useful links. I'm still noticing that the quality of the graphics (such as ellipse) is poor. I'm currently only looking at this in the simulator so I'm now going to set things up so I can run them on my iPad and see how they look there.

Ian
Alex Shy

Posts: 11
Registered: 8/9/07
Re: Drawing on Image (canvas?) in XE6, iOS  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 10, 2018 10:28 AM   in response to: Ian Johnson in response to: Ian Johnson
About poor quality.

To draw with FMX with High quality on Android\iOS use this modules:

http://www.cnblogs.com/onechen/p/6350096.html (use google translate)

https://github.com/OneChen/FMXNativeDraw/
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02