Articles in this section
Category / Section

How to load shapes with custom bounds?

3 mins read

SfImageEditor allows you to load shapes with custom bounds. You can define the location where the shapes need to be placed initially.

 

Step 1: Create image editor sample with all necessary assemblies.

 

Please refer the below link to create a simple SfImageEditor sample along with the ways to configure it.

https://help.syncfusion.com/xamarin/sfimageeditor/getting-started

 

Step 2: You can load any shapes (Circle, Rectangle and Text) with custom Bounds using AddShape method with parameter as specific shape type and PenSettings to set Bounds for shapes. Using Bounds property, you can position the shapes on the image at any place based on the given frame as like below,

C#

editor.AddShape(ShapeType.Circle, new PenSettings() { Color = Color.Green, Bounds = new Rectangle(0, 0, 30, 30) });

 

Note:

Bounds value (e.g. Bounds = new Rectangle (0, 0, 30, 30)) is represented by X position, Y position, width and height should be in percentage ranges from 0 to 100.

 

Similarly using AddText method, we can place the text in custom location like below code snippet.

C#

editor.AddText("Enter Text", new TextSettings() { Color = Color.Blue, Bounds = new Rectangle(0,50,30,30) });

 

Note:

If Bounds value is empty, then shapes will be placed on the center of the image.

 

Sample Link:

http://www.syncfusion.com/downloads/support/directtrac/general/ze/ShapesCustomBoundsSample-6564400751737577453.zip

Screenshot:

 

Shape with custom bounds using xamarin SfImageEditor

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied