gpt4 book ai didi

android - Google 关于 RenderScript 的代码不起作用?

转载 作者:行者123 更新时间:2023-11-29 15:04:40 28 4
gpt4 key购买 nike

我发现谷歌关于 RenderScript 的文档有更新(https://developer.android.com/guide/topics/renderscript/compute.html)。所以我用它的代码来测试但是我得到了一个错误

Error:(31, 23) error: implicit declaration of function 'rsCreateAllocation_uchar4' is invalid in C99
Error:(31, 17) error: initializing 'rs_allocation' (aka 'struct rs_allocation') with an expression of incompatible type 'int'

这是代码:

rs_allocation tmp = rsCreateAllocation_uchar4(imageWidth, imageHeight);
rsForEach(invert, inputImage, tmp);
rsForEach(greyscale, tmp, outputImage);

所以我想知道:1:为什么会这样(我认为 sdk api 是原因,但我已经将我的 AS、SDK 和 sdk 工具更新到最新)?2:有什么区别

uchar4 RS_KERNEL root(uchr4 in, unit32_t x, uint32_t y)

void RS_KERNEL root(uchr4* in, uchar4* out, unit32_t x, uint32_t y)

我觉得第二种方法更快?!但我不能确定。并且使用指针作为参数的方法未用于未命名为 root() 的函数(我对其进行了测试)。因此,如果使用指针参数的方法更快,我如何在 RS 文件中使用 2 个或更多内核函数?

最佳答案

rsCreateAllocation*() 函数仅在针对 Android Nougat(即 API 级别 24 及更高)时可用。我假设您收到此错误是因为您选择了比它低得多的 RenderScript 目标 API。

关于android - Google 关于 RenderScript 的代码不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39348939/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com