B4J Question XUI, B4XBitmap and Pane

Star-Dust

Expert
Licensed User
Longtime User
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
B4X:
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)
 

Star-Dust

Expert
Licensed User
Longtime User
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:
B4X:
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:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
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.:p
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Everything you need is already available.

Don't draw on the pane directly.
Code to create B4XCanvas:
B4X:
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

Star-Dust

Expert
Licensed User
Longtime User
Thank's. Good idea
 
Upvote 0
Top