Android draw with blur

I need to paint on Android Canvas using the Blur effect, this is a very simple function, I need to draw a circular area that is blurred (foreground) and a transparent background, I can do everything with alpha color manipulation to do it with custom transparency, but me you want it to be blurred instead of transparent. any ideas?

+4


source to share


3 answers


(For those returning, although this is an old question)

In the Paint object that is used to paint 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 a more detailed explanation, refer to Android BlurMaskFilter does not affect canvas.drawOval while text is blurry

+16


source


If you don't need to manipulate it after that, you can just draw the buffer and blur it pixel by pixel, then split that buffer onto the screen when you need to draw it.



Or this: http://developer.android.com/reference/android/graphics/BlurMaskFilter.Blur.html

0


source


Take a look at this: Android, Blur Bitmap instantly?

Again, I would recommend that you draw to a bitmap first. Decrease the scale (try different sizes) and the scale will return to its original size (either as a new bitmap, or if you are using hw acceleration, do so while you draw).

0


source







All Articles