Android Question Selection rectangle, or moving line

JeffT

Member
Licensed User
I want to be able to draw a selection rectangle under the control of the pointer.
I have read this post https://www.b4x.com/android/forum/threads/drawing-a-selection-window.7023/
BUT all that actually does is draw a black or white rectangle on a black background.

if I have a canvas that already has a picture in it, how do I draw such a rectangle without erasing the picture?

In the past I have used XOR drawing as one method - darw twice and it is back to normal

I have tried taking a copy of the image on TOUCH_ACTION_DOWN, to be able to DrawBitmap later
(bmp = mycanvas.snapshot)
But that line of code somehow 'freezes' the image so that I cannot draw on it at all.
 

JeffT

Member
Licensed User
I hadn't seen that booklet but it doesn't seem to offer me any clues.
Maybe I'm not understanding how to pivot what it does show.
 
Upvote 0

JeffT

Member
Licensed User
Does anyone have a simple example of what I think is called 'layers'?
I can imagine having a canvas over my main drawing area, but surely that would intercept pointer messages?
How can I get something to follow the pointer over a photo without wrecking the photo?
 
Upvote 0

JeffT

Member
Licensed User
Might it make sense to delete old posts like that, (which come up on top of the searches), if they are no longer useful?

I'll check this new link out, thank you Erel.

(It may have taken the 'selection rectangle on a photo' description too literally.
The thing I need to draw over is already the result of a set of drawing commands.
All attempts to turn that into an actual image (my 'photo') which can be drawn over have failed so far.
It feels like I need to associate 2 canvases with the same panel, to draw 'static' data in one and then overlay 'movable' data on top
I'll do some work and report back.)
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Attached a small project.

There are three Panels with a Canvas for each Panel.
pnlImage holding the image
pnlDrawing holding the selected rectangle
pnlDynamic showing the dynamic drawing during rectangle selection
 

Attachments

  • SimpleDrawing.zip
    55.2 KB · Views: 150
Upvote 0
Top