Happy NY, people !
Task is to properly scale the screenshots of various Android devices that got from remote devices and get the tap coordinate over them (for remote control).
I have
1) Screenshot that made by MediaProjection
2) And GetDeviceLayoutValues.Width and GetDeviceLayoutValues.Height of this device
1) Screenshots are different kind, if from different devices: if "old" device with mechanical\external system keys HOME, BACK, RECENT APPS - the screenshot has no these keys on the bottom.
If new device with the virtual system keys on the screen bottom - they are on the screenshot.
2) GetDeviceLayoutValues.Height - does not correspond the real screen vertical size in pixels, seem, the notification area (optionally) and\or Activity.Title height (also optionally) make influence...
But if to see the screenshot and making taps and swipes over them - the dimension and proportions must be exacly correct.
Super sub from Erel
helps not much.
Is there way to correct setup screenshots showing (on the fullscreen Activity, IncludeTitle=false) and tapping ?
Task is to properly scale the screenshots of various Android devices that got from remote devices and get the tap coordinate over them (for remote control).
I have
1) Screenshot that made by MediaProjection
2) And GetDeviceLayoutValues.Width and GetDeviceLayoutValues.Height of this device
1) Screenshots are different kind, if from different devices: if "old" device with mechanical\external system keys HOME, BACK, RECENT APPS - the screenshot has no these keys on the bottom.
If new device with the virtual system keys on the screen bottom - they are on the screenshot.
2) GetDeviceLayoutValues.Height - does not correspond the real screen vertical size in pixels, seem, the notification area (optionally) and\or Activity.Title height (also optionally) make influence...
But if to see the screenshot and making taps and swipes over them - the dimension and proportions must be exacly correct.
Super sub from Erel
B4X:
Sub FillImageToView(bmp As Bitmap, ImageView As View)
Dim bmpRatio As Float = bmp.Width / bmp.Height
Dim viewRatio As Float = ImageView.Width / ImageView.Height
If viewRatio > bmpRatio Then
Dim NewHeight As Int = bmp.Width / viewRatio
bmp = bmp.Crop(0, bmp.Height / 2 - NewHeight / 2, bmp.Width, NewHeight)
Else if viewRatio < bmpRatio Then
Dim NewWidth As Int = bmp.Height * viewRatio
bmp = bmp.Crop(bmp.Width / 2 - NewWidth / 2, 0, NewWidth, bmp.Height)
End If
ImageView.SetBackgroundImage(bmp.Resize(ImageView.Width, ImageView.Height, True))
End Sub
helps not much.
Is there way to correct setup screenshots showing (on the fullscreen Activity, IncludeTitle=false) and tapping ?
Last edited: