Articles in this section
Category / Section

How to add shapes to the Xamarin.Forms Image Editor on initial loading

1 min read

This article shows how the shapes in the image editor can be annotated on initial loading scenario. While programmatically adding a shape to the image editor, we can either fall into two valid scenarios with or without an image on the editor.

 

Shape was added with the help of AddShape() method, which passed the desired shape and its pen settings.

With Image

If the image has been loaded, you can add the shape to the ImageLoaded event as shown in the code snippet as follows.

 

editor.ImageLoaded += (Object sender, ImageLoadedEventArgs args) =>
 {
                  editor.AddShape(ShapeType.Circle,new PenSettings() { Color=Color.Green}); 
  } 

 

Output

Add shape when image loaded in SfImageEditor with image

Without Image

When image editor does not have a loaded image, add a shape with some time delay to the timer as shown in the code snippet as follows.

 

C#

   Device.StartTimer(TimeSpan.FromMilliseconds(1000), () =>
                {
                 editor.AddShape(ShapeType.Circle,new PenSettings() { Color=Color.Green});  
                    return false;
                });
 

 

Output

Add shape when loading ImageEditor without setting image

 

Download the complete sample here.

 

See Also:

 

How do I add a shape to an image?

 

How do I notify the image that is loaded in the SfImageEditor control?

 

How can I customize the appearance of the shape?

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