Did anyone try canvas drawing in FMX for iOS and Android target? Please let me know if this is supported or you know any work around.


Did anyone try canvas drawing in FMX for iOS and Android target? Please let me know if this is supported or you know any work around.

1. How to fill a path using Winding and Alternative modes?
2. Canvas.Stroke.Join, Canvas.SetCustomDash, Canvas.Stroke.Cap methods seems to have no effect on iOS and Android.

Code snippet:
var
LDash: array [0 .. 1] of Single;
LBitmap: TBitmap;
LPath: TPathData;
begin
LBitmap := TBitmap.Create(500, 500);
LPath := TPathData.Create;
LBitmap.Canvas.BeginScene();
LBitmap.Canvas.Clear(ClAWhite);
LBitmap.Canvas.Stroke.Color := ClABlack;
LBitmap.Canvas.StrokeThickness := 30;
LDash[0] := 3;
LDash[1] := 2;
LBitmap.Canvas.StrokeDash := TStrokeDash.sdCustom;
LBitmap.Canvas.Stroke.Dash := TStrokeDash.sdCustom;
LBitmap.Canvas.SetCustomDash(LDash, 2);
LBitmap.Canvas.Stroke.Join := TStrokeJoin.sjRound;
LPath.MoveTo(PointF(100, 100));
LPath.LineTo(PointF(400, 400));
LPath.LineTo(PointF(100, 400));
LPath.LineTo(PointF(400, 100));
LBitmap.Canvas.DrawPath(LPath, 255);
LBitmap.Canvas.EndScene();
Image1.Bitmap.Assign(LBitmap);

Comments

  1. No. I have also tried LBitmap.Canvas.StrokeDash := TStrokeDash.sdCustom;. But no change in behaviour.

    ReplyDelete
  2. Thanks. I have filed a QR.I will try using platform Graphics APIs for now.

    ReplyDelete
  3. Gil Padilla Its not due to UI update. The Bitmap saved to disk itself is wrong.

    ReplyDelete
  4. I have an old QC for sdCustom:
    http://qc.embarcadero.com/wc/qcmain.aspx?d=113884
    In the meanwhile I modified FMX.StrokeBuilder.pas and for me it's working.

    ReplyDelete
  5. Ramnish R I voted for https://quality.embarcadero.com/browse/RSP-15709
    But it's better to reduce the code to the minimum necessary to reproduce the issue.
    This way you have more chances for a solution.

    ReplyDelete
  6. It has to do with drawing in OpenGL. If you want to see the behavior on Windows set: initialization
    FMX.Types.GlobalUseGPUCanvas := True;

    Thomas Grubb knows about FMX drawing from his SVG components. He may know or have a workaround? http://www.riversoftavg.com/svg.htm

    I've seen other people run into this issue on the Embarcadero Forums but I'm not finding the thread right now besides https://forums.embarcadero.com/thread.jspa?messageID=821768

    ReplyDelete
  7. Cristian Peța Thanks . I will trim down the code. I'm surprised that this is not fixed in three years. :O

    ReplyDelete

Post a Comment