Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Drawing by finger?


This question is answered.


Permlink Replies: 3 - Last Post: Jan 25, 2018 3:59 PM Last Post By: Remy Lebeau (Te...
Krzysztof Bzoma

Posts: 7
Registered: 2/20/18
Drawing by finger?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 25, 2018 4:57 AM
I would like to make app where you can draw by finger (or fingers) on some TBitmap, i already load bitmap and know how draw figures on it but i have problem with adding touch mechanics to it. I think i should use GestureManager like here http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Gestures_in_FireMonkey but i don't know how draw this lines to be curve enough. I would like to be it like this:
1. I'm loading "clean" photo Bitmap and loading it into TImage. (Done)
2. User is making some "fancy" gestures, curves, circles, whatever he wants.
3. Using TBitmap->Canvas->??DrawLine or maybe DrawArc?? to draw those lanes on this TBitmap
4. Loading "new" Bitmap into TImage

Repeating points 2-4. How i should do it? I want like 1 touch mechanism for them all, doesn't matter if user make swipe, tab, double tap or just straight line. It should draw what he wants.
So my main question is how i can get touch coordinates to draw line properly on TImage panel. Anyone can help me with this ? I'm working on Rad Studio 10.2.
PS: Oh, and additional question to not ask 2nd time: Is there possibility of saving later that Bitmap into photo gallery (with those drawings of course)?

Edited by: Krzysztof Bzoma on Jan 25, 2018 12:44 PM

Remy Lebeau (Te...


Posts: 9,442
Registered: 12/23/01
Re: Drawing by finger? [Edit]
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 25, 2018 1:06 PM   in response to: Krzysztof Bzoma in response to: Krzysztof Bzoma
Krzysztof Bzoma wrote:

I think i should use GestureManager

Using the GestureManager is definately NOT the way to handle this
situation. It only works for pre-defined gestures, like swiping and
such. It is not suitable for free-form drawing.

I want like 1 touch mechanism for them all, doesn't matter if user
make swipe, tab, double tap or just straight line. It should draw what
he wants.

TImage has OnMouse... events (OnMouseDown, OnMouseMove, OnMouseUp).

In OnMouseDown, set a flag and save the current mouse position.

In OnMouseUp, clear the flag.

In OnMouseMove, if the flag is set, draw a line/arc from the saved
position to the current position, and then save the current position.

Is there possibility of saving later that Bitmap into photo gallery

Of course.

--
Remy Lebeau (TeamB)
Krzysztof Bzoma

Posts: 7
Registered: 2/20/18
Re: Drawing by finger?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 25, 2018 3:46 PM   in response to: Krzysztof Bzoma in response to: Krzysztof Bzoma
Yep, that working. Thx you for help. Only problem is that recognize only 1 finger drawing but it's still good. Once more thank you for your time.
Remy Lebeau (Te...


Posts: 9,442
Registered: 12/23/01
Re: Drawing by finger?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 25, 2018 3:59 PM   in response to: Krzysztof Bzoma in response to: Krzysztof Bzoma
Krzysztof Bzoma wrote:

Only problem is that recognize only 1 finger drawing

Right, because there is only 1 mouse cursor firing the events.

If you want to support events for multiple fingers, you will have to
use other platform-specific APIs for that (like handling
WM_NCPOINTER... and WM_POINTER... messages on Windows, etc).

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02