Sub Crop_Image(V As B4XView, left As Int, top As Int, width As Int, height As Int) As Bitmap
Dim Btm As Bitmap = V.Snapshot
Dim Canv As Canvas
Dim MyBitmap As Bitmap
MyBitmap.InitializeMutable(width,height)
Canv.Initialize2(MyBitmap)
Dim R As Rect
R.Initialize(left,top,width,height)
Dim R2 As TextReader
R2.Initialize(0,0,width,height)
Canv.DrawBitmap(Btm,R,R2)
Return Canv.Bitmap
End Sub
This code imports the background image of the view and cuts the square indicated by the coordinates (left, top, width, height) and returns the resulting bitmap
Sub Crop_Image(V As B4XView, left As Int, top As Int, width As Int, height As Int) As Bitmap
Dim Btm As Bitmap = V.Snapshot
Dim Canv As Canvas
Dim MyBitmap As Bitmap
MyBitmap.InitializeMutable(width,height)
Canv.Initialize2(MyBitmap)
Dim R As Rect
R.Initialize(left,top,width,height)
Dim R2 As TextReader
R2.Initialize(0,0,width,height)
Canv.DrawBitmap(Btm,R,R2)
Return Canv.Bitmap
End Sub
This code imports the background image of the view and cuts the square indicated by the coordinates (left, top, width, height) and returns the resulting bitmap
Sub ButtonCut_Click
Dim Canv As Canvas
Canv.Initialize(PanelMain)
Canv.DrawColor(Colors.Transparent)
Dim P As Path
P.Initialize(Point(0).X,Point(0).Y)
For i=1 To Point.Length-1
P.LineTo(Point(i).X,Point(i).Y)
Next
Canv.ClipPath(P)
Dim r As Rect
r.Initialize(0,0,PanelMain.Width,PanelMain.Height)
Canv.DrawBitmap(LoadBitmap(File.DirAssets,"cavallo_0.jpg"),Null,r)
End Sub
Sub ButtonCut_Click
Dim Canv As Canvas
Canv.Initialize(PanelMain)
Canv.DrawColor(Colors.Transparent)
Dim P As Path
P.Initialize(Point(0).X,Point(0).Y)
For i=1 To Point.Length-1
P.LineTo(Point(i).X,Point(i).Y)
Next
Canv.ClipPath(P)
Dim r As Rect
r.Initialize(0,0,PanelMain.Width,PanelMain.Height)
Canv.DrawBitmap(LoadBitmap(File.DirAssets,"cavallo_0.jpg"),Null,r)
End Sub
my problem is not the clipping with the fingers, but the cropping through a pre-set image as in the example I want to cut out only what is inside the t-shirt
my problem is not the clipping with the fingers, but the cropping through a pre-set image as in the example I want to cut out only what is inside the t-shirt
Yes, I understand, but in the meantime I have to do my job too.
You work too
This was easier to do. I'll have the rest when I can. Please note that the exterior of the preset images must have a black background (or any other color you have set)
As soon as I can tyi, I'll set an example for lunch now
Yes, I understand, but in the meantime I have to do my job too.
You work too
This was easier to do. I'll have the rest when I can. Please note that the exterior of the preset images must have a black background (or any other color you have set)
As soon as I can tyi, I'll set an example for lunch now
yes, obviously the t shirt will have only the transparent inside and the rest outside with a dark background. Okay, I'm waiting for your example in the day. Thanks so much
The best thing would be to recharge the points of the path from the frame and apply it to the photo.
To do this you have to create an algorithm that from the frame image you earn points, in itself it is not impossible and I have got at least 2 interesting ideas, but ... they would take time and if I did an algorithm like that I would keep it for myself .