B4J Question Rotated rectangle on B4XCanvas

max123

Well-Known Member
Licensed User
Longtime User
Hi everyone,

I'm converting my B4J application where I normally used a Canvas to use B4XCanvas.
Canvas has the DrawRectRotated method that I used but can't find this method in B4XCanvas.

I understand that I could use DrawBitmapRotated and create a runtime image (using BitmapCreator) by filling it pixel by pixels of the desired color, but is this the right way to draw the rotated rectangle as quickly as possible?

My application is time critical because it receives fast commands via WiFi (commands that draw) and I need that for performance reasons the rectangle be drawn as fast possible, before I receive next packet.

Is there any command using B4XCanvas which is the counterpart of Canvas DrawRectRotated?

I have two versions of my app, for B4J and for B4A so I need it work on both.

Many thanks
 
Last edited:

max123

Well-Known Member
Licensed User
Longtime User
.
But I've already answered that B4XCanvas = Canvas. The behavior is identical. It is just a cross platform API layer.
The Invalidate method doesn't do anything in B4J. It is there because it is required in B4A and B4i.

@Erel, but I've read Your post and the point 3. Call Invalidate to commit the drawings.confused me, because not specified only for B4A and B4i, sorry I misplaced it

.
B4XCanvas is the cross platform version of Canvas.

Steps to using B4XCanvas:

1. Initialize and pass the target view. In most cases it will be a Panel (or Pane). It must be a Pane in B4J.
2. Make the drawings.
3. Call Invalidate to commit the drawings.
4. If the target view is resized then you should call B4XCanvas.Resize. This is more relevant in B4J and B4i as the activity is recreated in B4A when the screen size changes.
5. B4XCanvas.CreateBitmap returns the drawings bitmap.
6. Call B4XCanvas.Release if the canvas is no longer required.

@udg and @sorex many thanks for your suggestions, I need to try it on the go, so next days I will try all my ESP demo sketches on witch I have even perfomance test, but Before it I will try that all works even with B4xCanvas, for now I've changed all references and some differences to it and my app compiles without errors and wait I test it with ESP.

Many thanks to all
 
Last edited:
Upvote 0

MicroDrie

Well-Known Member
Licensed User
A Remote Desktop Communication protocol has the same problem. There it is solved by simply first ignoring 1 and then more and more updates with fewer and fewer resources.

But a person also has a limit to what he or she can follow in real time. Perhaps then you can then proceed to just display a summation or situations to make room for processing even more updates in the same time period?
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
@MicroDrie for now no missed packets, all commands are received on remote side, just I need to optimize it because this is a base of more complex system, it is like an ESP-B4X small framework, as explained my ESP library do not just draw on Android and Desktop remote devices, but can do other things, like load images on remote devices internal memory on sd or hard disk and show at exact position with parameters like the original B4X drawBitmap, can create and write CSV files on remote devices, eg can log Analog (or digital) pins or other sensors directly on remote device. Can read all Android sensors and Android multitouch and more
 
Upvote 0
Top