iOS Question Sniper Effect

Descartex

Well-Known Member
Licensed User
Longtime User
Hi.
I need to implement a "sniper effect" on my image cropping code. I mean, it needs to behave similar to WhatsApp image selection...
I have a circle that limits the desired part of the pic, but i need to shadow the rest of the screen that is not inside this circle...
Thanks in advance.
 

Descartex

Well-Known Member
Licensed User
Longtime User
Sorry, but i dont understand what should i do...
I have the image loaded on a WebView to be able to zoom in and zoom out.
Above it, i have a panel with rounded corners that makes the selection to a canvas...
How can i delete the shadowed that is not within the selection panel?
Sorry, it can be obvious, but i dont see it...
 
Upvote 0

Descartex

Well-Known Member
Licensed User
Longtime User
This is my crop button code:
B4X:
imT.Initialize()
    Dim iv As ImageView
    iv.Initialize("")
    iv.SetLayoutAnimated(0, 1, 0,0,WebView1.Width,WebView1.Height)
    Dim cvs As Canvas
    cvs.Initialize(iv)
    cvs.DrawView(WebView1, cvs.TargetRect)
    Log(WebView1.Width)
    cvs.Refresh
    Dim bm As Bitmap
    bm=cvs.CreateBitmap
    ImageView1.Bitmap=bm
    Dim sx,sy As Float
    sx=ImageView1.Bitmap.Width/ImageView1.Width
    sy=ImageView1.Bitmap.Height/ImageView1.Height
    ImageView1.Bitmap=imT.CropImageRect(ImageView1.Bitmap,pnlCrop.Left*sx,pnlCrop.Top*sy,pnlCrop.Width*sx,pnlCrop.Height*sy)
Where imT is an ImageTransformation object.
Thanks.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
upload_2016-8-30_16-17-39.png


Check the attached example. The panel is not moved.
Instead a hole is drawn:
B4X:
Sub pnlCrop_Touch(Action As Int, X As Float, Y As Float)
   cvsCrop.DrawColor(0)
   cvsCrop.DrawColor(0xaa000000)
   cvsCrop.DrawCircle(X, Y, 100dip, 0, True, 0)
   cvsCrop.Refresh
End Sub

You will need to store the coordinates and later use them for the crop method (I haven't implemented it).
 

Attachments

  • CropImages.zip
    284.6 KB · Views: 262
Upvote 0

Descartex

Well-Known Member
Licensed User
Longtime User
Simply perfect.
Thank you so much.
 
Upvote 0
Top