Reputation: 515
is there any way to blur only part of an image in android?
searched a lot but dint find any help.
most of the examples use gaussian blur which blurs full imageview.
i want to allow user to dynamically draw rectangle on imageview & on action up area within rectangle should be blured.
any help will be really appreciated.
Upvotes: 1
Views: 1321
Reputation: 613
Bluring images on the fly is not an easy task, ask Roman Nurik (The one behind Muzei app) He gave useful tips on this Google+ post but it's for animated images, from focus to blur.
In your case, I would say that you need to (roughly):
EDIT: After re-thinking about it, computing and draw a blurred area each time the drawn rectangle move it too heavy, it won't work. The solution is probably this:
Upvotes: 4
Reputation: 229
This is code for blur: http://shaikhhamadali.blogspot.in/2013/07/gaussian-blur-imagebitmap-in-imageview.html
In this code computeConvolution3x3
method is used for computing the blur.For computing blur it convert the bitmap in to pixel array then it apply on those pixel. So you have to just do is get pixels array of that part of the image that you want blur.
Upvotes: 0
Reputation: 5176
Once you have drawn your rectangle set alpha = 0.5
or as per your need so that your dynamic view that you have drawn will look blurred.
Upvotes: 0
Reputation: 2773
put the image view in a relative layout. you detect the touch events of the user. for each rectangle that he is drawing, you add an image view of it is size superposed to the initial one (I mean in the same relative layout) and of course with your blur effect. you will see your image view blured part by part ...
Upvotes: 1
Reputation: 565
put another layout on the half part of the image and set a translucent type background to the layout.
Upvotes: 0