Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Converting TImage touch coordinates to TBitmap ones


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0 Threads: [ Previous | Next ]
Grigori Mystwi

Posts: 2
Registered: 2/27/18
Converting TImage touch coordinates to TBitmap ones  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 8, 2018 4:28 PM
Hello, I'm using CameraService to let camera make photo but i'm not saving it instantly. First i'm putting that photo into TImage as Bitmap and allowing user to draw on it as on canvas. My problem is:
Bitmap is never on whole TImage (which is align client) and i want to draw only on Bitmap and not on "frame" but i have coordinates from frame. So i was using formula as
TPointF *end = new TPointF(X-(float)((imageWidth-(float)bitmapWidth)/2),Y-(float)((imageHeight-(float)bitmapHeight)/2));
MyBitmap->Canvas->DrawLine(previousPoint,*end,1);

where previousPoint was just point made in same rules as this end one. It worked for my Android Phone (Samsung Galaxy A5 2016) and it drawed where i touched. But when i wanted to test in iPhone 5s which have smaller screen it problems started cause bitmap was bigger than TImage and was just scaled to place it properly. So when i started drawing it near middle of bitmap was ok but if i wanted to go more on side, line started to going even more than my finger.
TLDR; I'm looking how i can convert coordinates of touch (which i get from TImage) into proper coordinates of TBitmap without problems in size of bitmap. I'm adding code from CameraService because it's problem with photo size.
_di_IFMXCameraService service;
	TParamsPhotoQuery params;
	if (TPlatformServices::Current->SupportsPlatformService
		(__uuidof(IFMXCameraService)) && (service =
		TPlatformServices::Current->GetPlatformService
		(__uuidof(IFMXCameraService)))) {
		params.Editable = false;
		params.NeedSaveToAlbum = false;
		params.RequiredResolution = TSize(680 , 680);
		params.OnDidFinishTaking = DoDidFinish;
		service->TakePhoto(SpeedButton1, params);
 
	}
	else {
		ShowMessage("This device does not support the camera service");
	}


TImage wrapmode is in default fit state.

Is this even possible to do like this ? (To draw on bitmap where i touch)?

If it's not possible to do this in that way can someone show be better way to do this? If i would draw on TImage Canvas then if i will save Bitmap it will be without those drawings. Thats my problem.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02