Requirement:
Start image editor with active pen
Add editor.AddShape(ShapeType.Path) in
SfImageEditorPage in
OnAppearing() method
public class SfImageEditorPage : ContentPage
{
Syncfusion.SfImageEditor.XForms.SfImageEditor editor;
public SfImageEditorPage(ImageSource imagesource)
{
editor = new Syncfusion.SfImageEditor.XForms.SfImageEditor();
editor.Source = imagesource;
editor.RotatableElements = ImageEditorElements.Text;
Content = editor;
}
protected override void OnAppearing()
{
base.OnAppearing();
editor.AddShape(ShapeType.Path);
}
}
Testing repo attached:
- see code in xamarin-demos-master\Forms\ImageEditor\ImageEditor\Samples\ImageEditor\ImageEditor.xaml.cs
UWP: working
iOS: not tested
Android: exception - Java.Lang.IllegalArgumentException: width and height must be > 0
Exeption:
Java.Lang.IllegalArgumentException: width and height must be > 0
at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in :0
at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters) [0x00018] in :0
at Android.Graphics.Bitmap.CreateBitmap (System.Int32 width, System.Int32 height, Android.Graphics.Bitmap+Config config) [0x0005a] in <11a340ccc8de43f09c97400139266ef5>:0
at Syncfusion.SfImageEditor.Android.SfImageEditor.SetShapeView () [0x00083] in :0
at Syncfusion.SfImageEditor.Android.SfImageEditor.AddShape (Syncfusion.SfImageEditor.Android.ShapeType shapeType, Syncfusion.SfImageEditor.Android.PenSettings penSettings) [0x00014] in :0
at Syncfusion.SfImageEditor.XForms.Droid.ImagEditorDependencyServiceMapping.AddShape (System.Object obj, Syncfusion.SfImageEditor.XForms.ShapeType shapeType, Syncfusion.SfImageEditor.XForms.PenSettings settings) [0x0003a] in :0
at Syncfusion.SfImageEditor.XForms.SfImageEditor.AddShape (Syncfusion.SfImageEditor.XForms.ShapeType shapeType, Syncfusion.SfImageEditor.XForms.PenSettings settings) [0x00014] in <33003be31fcb4cbda8fd715f3b7d824f>:0
at SampleBrowser.SfImageEditor.SfImageEditorPage.OnAppearing () [0x00009] in c:\Examples 2019 - 10\xamarin-demos-master\Forms\ImageEditor\ImageEditor\Samples\ImageEditor\ImageEditor.xaml.cs:185
--- End of managed Java.Lang.IllegalArgumentException stack trace ---
java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:829)
at android.graphics.Bitmap.createBitmap(Bitmap.java:808)
at android.graphics.Bitmap.createBitmap(Bitmap.java:775)
at md51558244f76c53b6aeda52c8a337f2c37.PageRenderer.n_onAttachedToWindow(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.PageRenderer.onAttachedToWindow(PageRenderer.java:55)
at android.view.View.dispatchAttachedToWindow(View.java:14548)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2838)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2845)
at android.view.ViewGroup.addViewInner(ViewGroup.java:4350)
at android.view.ViewGroup.addView(ViewGroup.java:4147)
at android.view.ViewGroup.addView(ViewGroup.java:4088)
at android.view.ViewGroup.addView(ViewGroup.java:4061)
at md51558244f76c53b6aeda52c8a337f2c37.InnerGestureListener.n_onSingleTapUp(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.InnerGestureListener.onSingleTapUp(InnerGestureListener.java:79)
at android.view.GestureDetector.onTouchEvent(GestureDetector.java:635)
at md51558244f76c53b6aeda52c8a337f2c37.ImageRenderer.n_onTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.ImageRenderer.onTouchEvent(ImageRenderer.java:45)
at android.view.View.dispatchTouchEvent(View.java:9297)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2549)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2240)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.dispatchTouchEvent(VisualElementRenderer_1.java:65)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.dispatchTouchEvent(VisualElementRenderer_1.java:65)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.dispatchTouchEvent(VisualElementRenderer_1.java:65)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.dispatchTouchEvent(PlatformRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2445)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent_aroundBody0(PhoneWindow.java:1756)
at com.android.internal.policy.PhoneWindow$AjcClosure1.run(PhoneWindow.java:1)
at android.view.PhoneWindowAO.ajc$around$android_view_PhoneWindowAO$2$99ce526bproceed(PhoneWindowAO.aj:113)
at android.view.PhoneWindowAO.ajc$around$android_view_PhoneWindowAO$2$99ce526b(PhoneWindowAO.aj:117)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1756)
at android.app.Activity.dispatchTouchEvent(Activity.java:2800)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2406)
at android.view.View.dispatchPointerEvent(View.java:9517)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4309)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4175)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3682)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3735)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3701)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3709)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3682)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3735)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3701)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3828)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3709)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3885)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3682)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3735)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3701)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3709)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3682)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6001)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5975)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5936)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6133)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6083)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6156)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:600)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5525)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)