Android draw with blur

前端 未结 3 2097
清歌不尽
清歌不尽 2020-12-28 23:20

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 tr

相关标签:
3条回答
  • 2020-12-28 23:42

    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

    0 讨论(0)
  • 2020-12-28 23:50

    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).

    0 讨论(0)
  • 2020-12-28 23:55

    (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

    0 讨论(0)
提交回复
热议问题