I need do draw on Android's Canvas using Blur effect, it is a very simple feature, I need to draw a circular area, which is blurred (the foreground) and the background transparent, I can do everything with manipulating the colour alpha to do it with custom transparency but I need it to be blurred instead of transparent.. any ideas?
3 Answers
(For those who are coming back, though this is an old question)
On the Paint object which you are using to draw the Color, set
paint.setMaskFilter(new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL))
Then, in Android Manifest.xml, set
android:hardwareAccelerated="false"
for your activity (Blur doesn't work when hardware acceleration is true)
For more explanation refer Android BlurMaskFilter has no effect in canvas.drawOval while text is blurred

- 1
- 1

- 708
- 2
- 7
- 19
-
It just blurs to the applied drawing and not the background of it, eg: i draw 2 rectangles on top of each other, top 1 is blurred but it doesn't show effect on background 1 – Cyph3rCod3r Sep 17 '22 at 20:22
Take a look at this: Android, Blur Bitmap instantly?
Again I would recommend you first to draw into a bitmap. Scale it down (try different sizes), and the scale it back up to the original size (either as a new bitmap or if you use hw acceleration do it while you draw).

- 1
- 1

- 3,327
- 2
- 18
- 29
If you're not gonna need to manipulate it afterwards you could just draw to a buffer and blur it yourself pixel by pixel, then blit that buffer to screen when you need to paint it.
Or this: http://developer.android.com/reference/android/graphics/BlurMaskFilter.Blur.html

- 39,912
- 17
- 102
- 155
-
Well, BlurMaskFilter, will not cut it since it will only blur the edges, I need the blur to be evenly distributed trough the object (circle), and with blurmaskfilter, I can only "sharpen the edges" – Tancho Dec 30 '09 at 13:10