【发布时间】:2019-05-25 18:27:33
【问题描述】:
我看了这个例子https://github.com/googlesamples/android-BasicRenderScript。在那个项目中,他们有以下行:
mInAllocation = Allocation.createFromBitmap(rs, mBitmapIn);
其中 mBitmapIn 是表示要处理的图像的位图类型。 之后,他们通过AsyncTask异步调用.rs文件中名为saturation的内核函数:
mScript.forEach_saturation(mInAllocation, mOutAllocations[index]);
在saturation.rs 文件中,它们有:
uchar4 __attribute__((kernel)) saturation(uchar4 in)
{
float4 f4 = rsUnpackColor8888(in);
...
从这个线程Renderscript, what is the `in` parameter?我知道参数'in'指向要处理的数据(在我们的例子中是一个像素,对吗?)所以,我知道一个像素由4个颜色通道组成,因此他们使用 uchar4 ,它是 4 个 uchar 的向量(参见 https://developer.android.com/guide/topics/renderscript/reference/rs_value_types.html#android_rs:uchar4 )。但是为什么是 uchar 呢?为什么不呢,比如说 uint4 ?还是直接ufloat4??
【问题讨论】:
标签: android types parameters renderscript