Android implements Gaussian blur of pictures (two ways)

Many apps on the market use the effect of blurring the picture as the background to make the whole page more holistic. The following is the music playing page of Netease cloud music:

Obviously, the background of this page is blurred by the small picture in the middle. The most commonly used fuzzification is Gaussian fuzzification.

Several implementations of Gaussian blur:

(1)RenderScript

Renderscript is a high-performance image processing framework introduced by Google in Android 3.0 (API 11).

Gaussian blur using rendersriprt:

First, add the usage configuration of renderscript in the defaultconfig of build.gradle

renderscriptTargetApi 24 renderscriptSupportModeEnabled true

renderscriptTargetApi :

Specifies the bytecode version to generate. We (goole official) recommend that you set this value to the lowest API level, which can provide all functions. You can use and set renderscriptsupportmodeenabled to true. Valid values for this setting are any integer value from 11 to the recently published API level.

renderscriptSupportModeEnabled:

Specifies that the generated bytecode should fall back to a compatible version if the running device does not support the target version.

The following is how to use rendersriprt to realize Gaussian blur:

(2) Glide to achieve Gaussian blur

Glide is a powerful and commonly used image loading library. Transformations in glide are used to process images before they are displayed. Glide transformations this library provides glide with a variety of transformations implementations, including the implementation of Gaussian blur and blurtransformation

Through the combination of the two libraries, we can use the blurtransformation to realize the Gaussian blur of the picture

The value range of radius is 1-25. The larger the radius, the higher the ambiguity.

The above is Xiaobian's introduction to the Gaussian blur of Android images. I hope it will help you. If you have any questions, please leave me a message and Xiaobian will reply to you in time!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>