Android Question How to cut an image with my fingers?

Matteo Granatiero

Active Member
Licensed User
I need to cut out an image with my fingers, and that the hatching appears and obviously the cut part will be darkened to make it clear that it will be cut out. Then with a button confirm the whole and the part cut out (darkened) will become transparent
 

klaus

Expert
Licensed User
Longtime User
This is done here:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("lyDraw")

bmpImage=LoadBitmap(File.DirAssets,"charly.jpg")
bmpWidth = bmpImage.Width
bmpHeight = bmpImage.Height

'sets the panel aspect ratio to the image aspect ratio
If bmpWidth / bmpHeight > pnlImage.Width / pnlImage.Height Then
    pnlImage.Height = bmpHeight * pnlImage.Width / bmpWidth
Else
    pnlImage.Width = bmpHeight * pnlImage.Height / bmpHeight
End If
'save the original panel size
pnlImageWidth = pnlImage.Width
pnlImageHeight = pnlImage.Height
But if you load a new bitmap you must adapt the aspect ratio if it's different, otherwise the image in the panel will be distorted, streched or compressed in one direction.
That's the reason why I put it in.
 
Upvote 0

Matteo Granatiero

Active Member
Licensed User
Then I need another solution to my problem.
Because when the panel loads the image it becomes a bit smaller and I do not want it to happen. I tried with the panel anchor but it does not solve the problem. That's why I would like the panel control to always be the same size
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Because when the panel loads the image it becomes a bit smaller and I do not want it to happen.
What do you mean with smaller?
The panel dimensions are adapted to the bitmap aspect ratio and the bitmap fills it.
Depending on the panel size and device density the canvas bitmap will have different bit sizes.
But the cropped image is saved with the original bit size.
In the Designer you can increase the panel size with anchors, but anyway you must adapt the aspect ratio!
 
Upvote 0
Top