Android Question B4XImageView

Sergey_New

Well-Known Member
Licensed User
Longtime User
How can I draw a line on top of an image on B4XImageView?
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
Thanks for the tip! I was thinking about that too, but I'd like to use only B4XImageView.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Place a transparent panel...
I can't bind line coordinates to an image.
Let me try to explain my actions.
The dimensions and position of the B4XImageView are maintained using mBase properties.
I need to bind line coordinates to a Bitmap that can have different dimensions.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
I would have thought that you have two approaches here. I am assuming that you know the position offsets of the corners of the imageView relative to your mBase.

1. You position the transparent panel over the image view - ie offset the panel from the mBase origin. Then draw using coordinates relative to the imageView - as before.

2. You cover the mBase with the transparent panel but offset you drawn line by adding the cordinates of the image view relative to the mBase.

If this does not make sense then maybe you can post a mini-project that contains an example of your mBase/imageView setup.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
I made an example, which I attached.
It turned out to be quite complicated, but in general, the problem is solved.
Two things confuse me:
- slightly different mBase sizes (see logs),
- the drawn lines go slightly beyond the mBase sizes.
Perhaps it was necessary to take into account the thickness of the lines.
 

Attachments

  • test.zip
    4.6 KB · Views: 68
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
- slightly different mBase sizes (see logs),
- the drawn lines go slightly beyond the mBase sizes.
This is due to the calculation of 'd'. In landscape on my phone it has the value 77, but in portrait it is 77.5 - and so gets rounded up to 78. That accounts for the difference of two pixels when the diagonal is drawn, I think.
 
Upvote 0

Similar Threads

Top