I use this code in b4j to get the Snapshot of a BBCodeView. It works well.
I always fall in this exception (IllegalArgumentException) java.lang.IllegalArgumentException: width and height must be > 0 in b4a what could be the issue ?
B4X:
Dim v As B4XView = BBCodeViewTicket.ForegroundImageView.Parent
Dim B4XTicketBitmap As B4XBitmap = v.Snapshot
Dim Out As OutputStream
Out = File.OpenOutput(xui.DefaultFolder, "TicketPage.png", False)
B4XTicketBitmap.WriteToStream(Out, 100, "PNG")
Out.Close
B4X:
java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:1197)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1163)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1111)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1070)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.InitializeMutable(CanvasWrapper.java:654)
at anywheresoftware.b4a.objects.B4XViewWrapper.Snapshot(B4XViewWrapper.java:361)
at ca.purpos.admin.dashboardpage$ResumableSub_btnPrintTicketOrder_Click.resume(Unknown Source:1582)
at ca.purpos.admin.dashboardpage._btnprintticketorder_click(Unknown Source:29)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7659)
at android.view.View.performClickInternal(View.java:7636)
at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
at android.view.View$PerformClick.run(View.java:30156)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Last edited: