Implementation of Gaussian blur in Android renderscript

Yesterday, I read the official documents of renderscript and found that renderscript is a bit awesome. Inadvertently found that the abstract class scriptintrinsic has some useful subclasses. One of the subclasses is called scriptintrinsicblur class, which roughly realizes Gaussian blur of pictures.

Scriptintrinsic's statement:

Declaration of scriptintrinsicblur class:

In addition, I read the samples in the SDK and wrote a Gaussian blur. (the specific location of the sample is: SDK directory / samples / android-19 / renderscript / renderscriptintrinsic / renderscriptintrinsicsample /).

Start with the picture above. The effects are as follows:

[note!! before starting, we need to import the required support package. The specific path of the support package is: SDK directory / buildtools / any version number / renderscript / lib / renderscript-v8.jar. In addition, in order to prevent compatibility problems with some models, it is best to copy renderscript-v8.jar and all libraries in the packaged directory to the Lib folder]

For example:

okay. Start writing code..

1. Declare common member variables first.

2. Load two bitmaps and initialize Gaussian blur related objects.

3. Complete Gaussian blur processing code.

4. Set the processed bitmap to ImageView.

The basic work has been completed. The rest is the mutual call of code.

[summary] in fact, in general, Gaussian blur using renderscript is mainly divided into three steps:

1. Create and initialize the required objects (initialization once is OK).

2. Perform Gaussian blur and copy the results.

3. Recycle renderscript objects

This concludes the article.

By convention: here is my complete code implementation.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

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
分享
二维码
< <上一篇
下一篇>>