Star-Dust Expert Licensed User Longtime User Jun 11, 2018 #1 I started trying the muio code XUi pe ril 3D with B4J. Using the first part of the renderiung that deals with polygons uses B4XCanvas that works correctly. A second part uses BitmapCreator. For B4A I used the last version but in B4J there is not yet. At the end of the code I apply BitmapCreator in the Bread like this Code: Copy Pane.SetBitmap(BitmapCreator.Bitmap.Resize(Pane.Width,Pane.height,False)) In B4A it works while in B4J it generates me this error ... Waiting for debugger to connect... Program started. Errore nella linea: 234 (BitmapCreator) java.lang.ClassCastException: anywheresoftware.b4j.objects.PaneWrapper$ConcretePaneWrapper$NonResizePane cannot be cast to javafx.scene.image.ImageView at anywheresoftware.b4j.objects.ImageViewWrapper.SetImage(ImageViewWrapper.java:99) at anywheresoftware.b4j.objects.B4XViewWrapper.SetBitmap(B4XViewWrapper.java:492) at b4j.example.vector3d._rendertoview(vector3d.java:571) at b4j.example.main._spinnerobiect_valuechanged(main.java:385) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:625) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:168) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:94) at anywheresoftware.b4a.BA$1.run(BA.java:215) at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177) at java.lang.Thread.run(Thread.java:748) Click to expand...
I started trying the muio code XUi pe ril 3D with B4J. Using the first part of the renderiung that deals with polygons uses B4XCanvas that works correctly. A second part uses BitmapCreator. For B4A I used the last version but in B4J there is not yet. At the end of the code I apply BitmapCreator in the Bread like this Code: Copy Pane.SetBitmap(BitmapCreator.Bitmap.Resize(Pane.Width,Pane.height,False)) In B4A it works while in B4J it generates me this error ... Waiting for debugger to connect... Program started. Errore nella linea: 234 (BitmapCreator) java.lang.ClassCastException: anywheresoftware.b4j.objects.PaneWrapper$ConcretePaneWrapper$NonResizePane cannot be cast to javafx.scene.image.ImageView at anywheresoftware.b4j.objects.ImageViewWrapper.SetImage(ImageViewWrapper.java:99) at anywheresoftware.b4j.objects.B4XViewWrapper.SetBitmap(B4XViewWrapper.java:492) at b4j.example.vector3d._rendertoview(vector3d.java:571) at b4j.example.main._spinnerobiect_valuechanged(main.java:385) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:625) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:168) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:94) at anywheresoftware.b4a.BA$1.run(BA.java:215) at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177) at java.lang.Thread.run(Thread.java:748) Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Jun 11, 2018 #2 Check the documentation of B4XView.SetBitmap: https://www.b4x.com/android/help/xui.html#b4xview_setbitmap Upvote 0
Check the documentation of B4XView.SetBitmap: https://www.b4x.com/android/help/xui.html#b4xview_setbitmap
Star-Dust Expert Licensed User Longtime User Jun 11, 2018 #3 You're right Erel, I forgot that it should be used with ImageView. I had changed because I had difficulty between B4XCanvas with ImageView. I'm continuing with B4XCanvas and BitmapCreator I use it with B4XCanvas this way: Code: Copy Dim Can as B4XCanvas Dim Rec As B4XRect Can.Initialize(Panel) Rec.Initialize(0,0,Panel.Width,Panel.Height) Can.DrawBitmap(BitmapCreator.Bitmap.Resize(Panel.Width,Panel.Height,False),Rec) Can.Invalidate Last edited: Jun 11, 2018 Upvote 0
You're right Erel, I forgot that it should be used with ImageView. I had changed because I had difficulty between B4XCanvas with ImageView. I'm continuing with B4XCanvas and BitmapCreator I use it with B4XCanvas this way: Code: Copy Dim Can as B4XCanvas Dim Rec As B4XRect Can.Initialize(Panel) Rec.Initialize(0,0,Panel.Width,Panel.Height) Can.DrawBitmap(BitmapCreator.Bitmap.Resize(Panel.Width,Panel.Height,False),Rec) Can.Invalidate
Erel B4X founder Staff member Licensed User Longtime User Jun 12, 2018 #4 This is a quite slow solution. It is better to add an ImageView to the panel and set the image with ImageView.SetBitmap(BitmapCreator.Bitmap). Upvote 0
This is a quite slow solution. It is better to add an ImageView to the panel and set the image with ImageView.SetBitmap(BitmapCreator.Bitmap).
Star-Dust Expert Licensed User Longtime User Jun 12, 2018 #5 True, the solution is slow. However, it is not known on the computer. Obviously I prefer a solution that goes well for Android/iOS/Windows. Maybe implement DrawLine and DrawRec for BitmapCreator and so drank to use B4XCANVAS. I always hope that in the next version of BitmapCreator there are already. Upvote 0
True, the solution is slow. However, it is not known on the computer. Obviously I prefer a solution that goes well for Android/iOS/Windows. Maybe implement DrawLine and DrawRec for BitmapCreator and so drank to use B4XCANVAS. I always hope that in the next version of BitmapCreator there are already.
Erel B4X founder Staff member Licensed User Longtime User Jun 12, 2018 #6 Everything you need is already available. Don't draw on the pane directly. Code to create B4XCanvas: Code: Copy Public Sub CreateCanvas (Width As Int, Height As Int) As B4XCanvas Dim p As B4XView = xui.CreatePanel("") p.SetLayoutAnimated(0, 0, 0, Width, Height) Dim cvs As B4XCanvas cvs.Initialize(p) Return cvs End Sub Use ImageView on all platforms. Upvote 0
Everything you need is already available. Don't draw on the pane directly. Code to create B4XCanvas: Code: Copy Public Sub CreateCanvas (Width As Int, Height As Int) As B4XCanvas Dim p As B4XView = xui.CreatePanel("") p.SetLayoutAnimated(0, 0, 0, Width, Height) Dim cvs As B4XCanvas cvs.Initialize(p) Return cvs End Sub Use ImageView on all platforms.
Erel B4X founder Staff member Licensed User Longtime User Jun 12, 2018 #8 Also don't call Resize. The size of BitmapCreator should be (ImageView.Width / xui.Scale, ImageView.Height / xui.Scale) The canvas size should be the same. Upvote 0
Also don't call Resize. The size of BitmapCreator should be (ImageView.Width / xui.Scale, ImageView.Height / xui.Scale) The canvas size should be the same.