B4J Question Canvas.DrawImage works slowly

red30

Well-Known Member
Licensed User
Longtime User
I use two canvases that show a signal.
When I use one - it runs smoothly, when both - with breaks. Why?
One:
B4X:
CanvasNCH.DrawImage(CanvasNCH.Snapshot,-1,0,CanvasNCH.Width,CanvasNCH.Height) 
CanvasNCH.DrawLine(t-2,OldSig1,(t-1),Sig1,fx.Colors.Blue,2)
OldSig1=Sig1
CanvasVCH.DrawLine(t-2,OldSig2,(t-1),Sig2,fx.Colors.Green,2)
OldSig2=Sig2
Both:
B4X:
CanvasNCH.DrawImage(CanvasNCH.Snapshot,-1,0,CanvasNCH.Width,CanvasNCH.Height)
CanvasVCH.DrawImage(CanvasVCH.Snapshot,-1,0,CanvasVCH.Width,CanvasVCH.Height)
CanvasNCH.DrawLine(t-2,OldSig1,(t-1),Sig1,fx.Colors.Blue,2)
OldSig1=Sig1
CanvasVCH.DrawLine(t-2,OldSig2,(t-1),Sig2,fx.Colors.Green,2)
OldSig2=Sig2
 

red30

Well-Known Member
Licensed User
Longtime User
In oder not to stop the graph: so the line keeps up moving right when the graph transfers to left.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
SS-2018-05-09_16.04.25.png


Attached is an example that uses BitmapCreator to create a similar graph.

Note that BitmapCreator will be included as an internal library in the next version of B4J to make it easier to use.
You will need to replace it with the class.
 

Attachments

  • Oscilloscope.zip
    3.3 KB · Views: 252
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
Erel, thank you very much, it is exactly what I needed, but still I have some questions.
Is it possible to put numbers on a scale (for ex. voltage on y-axis and time on y-axis)?
How can I change the grid itself? ( ex. 10x10 20x20)
Can it show the coordinate when hovering a cursor over the graph?
Can I change the scale of the graph on axises while it is building?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Example with text is attached.

SS-2018-05-10_09.00.26.png


In this implementation it only draws the text when there is enough room for the complete label. It can be further improved to make it appear immediately.

How can I change the grid itself? ( ex. 10x10 20x20)
You need to go over the code and see how it works.

You will need to wait for the next version of B4J (to be released next week) in order to run it.
 

Attachments

  • Oscilloscope.zip
    3.7 KB · Views: 258
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
In the last program produces an error:
B4X:
B4J Version: 6.01
Parsing code.    (0.03s)
Compiling code.    Error
Error compiling program.
Error description: Unknown member: measuretext
Error occurred on line: 117
Dim r As B4XRect = cvs.MeasureText(Text, fnt)
Word: measuretext
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
A new version of B4J has been released. But I can not figure out how to work with the schedule. Could you explain to me?
 
Upvote 0
Top